# Setup Git for CICD

**Step 1:** Create a account in Gitlab using email address. We can use free as well. Provide a repository name with permission.&#x20;

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

**Step 2**: Clone the repository with SSH which helps to edit the code easily using different IDE. <br>

```
git clone git@gitlab.com......
```

**Step 3:**  Open the folder in VS code and starting writng a script in .gitlab-ci.yml.\
In the following script I am using docker to build a CI/CD pipeline. In order to use a docker we need to have docker in docker hub and create a Dockerfile folder. Include image with version and mention port number in dockerfile.

<pre><code><strong>Stages:
</strong><strong>    - test
</strong><strong>    - build
</strong><strong>    - stg
</strong><strong>    - production
</strong><strong>    
</strong><strong>test artifacts:
</strong>    stage: test
    image: python:3.9-slim-buster
    before_script:
        - apt-get update &#x26;&#x26; apt-get install make
    script:
        - mkdir /data
        - cd /data
        - touch rajan.txt
        -  echo "Rajan Silwal" > rajan.txt


build the car:
    stage: build
    image: docker:20.10
    services:
        - docker::20.10-dind
    variables:
        DOCKER_TLS_CERTFIR: "/certs"
    before_script:
        - docker login -u $REGISTRY_USER -p $REGISTRY_PASS
    script:
        - docker build -f Dockerfile -t rajansilwal04/cicd:python-app-1.0 . 
        - docker push rajansilwal04/cicd:python-app-1.0 

testing staging:
    stage: stg
    image: python:3.9-slim-buster
    before_script:
        - apt-get update &#x26;&#x26; apt-get install make
    script:
        - mkdir /data
        - cd /data
        - touch rajan.txt
        -  echo "Rajan Silwal" > rajan.txt

Production:
    stage: production
    image: python:3.9-slim-buster
    before_script:
        - apt-get update &#x26;&#x26; apt-get install make
    script:
        - mkdir /data
        - cd /data
        - touch rajan.txt
        -  echo "Rajan Silwal" > rajan.txt
</code></pre>

**Step 4:** Once you done with your code you can commit and push into a git. It will automatically start running CICD pipeline in gitlab.\
\
We can see the pipeline under CICD menu.<br>

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

If you want to see the log of pipeline, We can see that logs under jobs.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rajan-silwal-1.gitbook.io/product-docs/git/ci-cd-in-git/setup-git-for-cicd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
