> For the complete documentation index, see [llms.txt](https://rajan-silwal-1.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rajan-silwal-1.gitbook.io/product-docs/git/ci-cd-in-git/setup-git-for-cicd.md).

# 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="https://1186894440-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9wnMXVEmEJ7k6VEhLJYN%2Fuploads%2FbTmIQfSt2Ckc4m3tVemG%2FScreen%20Shot%202022-11-05%20at%205.19.13%20PM.png?alt=media&amp;token=dbf000be-f355-415a-96b7-6b7750488f69" 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="https://1186894440-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9wnMXVEmEJ7k6VEhLJYN%2Fuploads%2F9kRRqVRe3Uv8k9seYtlk%2FScreen%20Shot%202022-11-05%20at%205.17.02%20PM.png?alt=media&amp;token=9f61cf4d-cf0a-44ac-ad2a-fce26e01a69e" alt=""><figcaption></figcaption></figure>

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