> For the complete documentation index, see [llms.txt](https://blog.securescape.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.securescape.cc/offensive-security/red-team/offensive-development/offensive-devops/gitlab/making-our-ci-cd-pipeline.md).

# 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)

[Templates](https://docs.gitlab.com/ee/ci/examples/)

[Syntax Reference](https://docs.gitlab.com/ee/ci/yaml/)

{% code title=".gitlab-ci.yml" %}

```yaml
image: golang:1.22  

stages:
  - test
  - build

build:
  stage: build
  script:
    - "go build -o calculator"
    - "./calculator"

test:
  stage: test
  script:
    - "go test"
```

{% endcode %}

Paste the code then push it to your repository

```bash
> 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**

<figure><img src="/files/jxaASxNib1Ly5qyew80f" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/38dtttuVaJCiDpHYt5th" alt=""><figcaption><p>Successful Build</p></figcaption></figure>

{% hint style="warning" %}
**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
{% endhint %}

### Testing for Failures

Just like in [Simple Calculator Project](/offensive-security/red-team/offensive-development/offensive-devops/gitlab/simple-calculator-project.md), 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

<figure><img src="/files/xPFL5zmUfha3IteKRQog" alt=""><figcaption><p>Creating a new branch with VS Code</p></figcaption></figure>

<figure><img src="/files/PWbX5C7vYVbALOlGU8QD" alt=""><figcaption><p>Editing calculator_test.go</p></figcaption></figure>

Push your changes then wait for the pipeline to finish running

<figure><img src="/files/9aIZuCnxn6gpU4vkmkhv" alt=""><figcaption><p>Failure Test</p></figcaption></figure>

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)

<figure><img src="/files/BIhs9zmSrlIK4jmidmsW" alt=""><figcaption></figcaption></figure>
