Making our CI/CD Pipeline
Config File
To create our pipeline, we must first create a .gitlab-ci.yml
file and specify it to our project requirements (Place this in your project root)
image: golang:1.22
stages:
- test
- build
build:
stage: build
script:
- "go build -o calculator"
- "./calculator"
test:
stage: test
script:
- "go test"
Paste the code then push it to your repository
> git add .\.gitlab-ci.yml
> git commit -m "Created GO Pipeline"
> git push
We can now view our pipeline from the repository, under Build -> Pipeline -> Pipeline Number
Viewing our deployed pipeline


Issues Faced
Spent the better part of an hour debugging and figured out that you need to create a runner as root cause of docker permissions. Alternatively, you can add yourself to the docker group - although it's easier just to use sudo
Testing for Failures
Just like in Simple Calculator Project, we can test for failures by changing the values slightly
First, we'll create a separate branch to mimic a real project, then change the test values from there


Push your changes then wait for the pipeline to finish running

We can now fix it back and create a merge request to main. Merge requests will trigger a pipeline job to check for errors before letting you merge (depending on your project settings)

Last updated
Was this helpful?