Run your first GitLab CI CD pipeline [2 Steps]

In this article we are going to cover How to Create and run your first GitLab CI CD pipeline, check available runner, create .gitlab-ci.yml file, check the status of your pipeline and jobs, edit yaml file and delete .gitlab-ci.yml file.

What is CI/CD pipeline ?

A CI/CD pipeline is a sequence of steps that smooth the software delivery process. Through a DevOps, CI/CD enhance application development using monitoring and automation. A CI/CD pipeline is particularly useful when it comes to integration and continuous testing, which are typically difficult to perform, time-consuming, and require the creation of stubs and drivers. Each an every step of a CI/CD pipeline is a subset of tasks grouped into pipeline stages.

Prerequisites:

  • GitLab Account

How to Create and run your first GitLab CI CD pipeline

Step #1:To check available runner in GitLab CI/CD.

Optional step: Make sure that you have runners available to run your jobs/project. If you are work on GitLab.com then avoid this step because GitLab issues shared runners by default.

How to check available runner in GitLab ?

To check available runners:

Go to particular Project ->Settings -> CI/CD ->Runner  and expand Runners.

Minimum one runner is active with a green color next to it, to process your jobs.

Step #2:To create .gitlab-ci.yml file in GitLab CI/CD.

You have to create yaml file in your repository. A YAML file where you specify instructions for GitLab CI/CD.

Now create a .gitlab-ci.yml file: Go to specific project -> in left side bar -> Code > Repository.

Run your first GitLab CI CD pipeline [2 Steps] 1

Select the branch which you want to commit to. Then select the plus icon and click on New file.

Run your first GitLab CI CD pipeline [2 Steps] 2

Enter the Filename .gitlab-ci.yml and write down code in the larger window.

stages: 
    - build
    - test
    - deploy

build-my-first-job:
    stage: build
    script:
        - echo "this is first build job."

test-my-first-job:
    stage: test
    script:
        - echo "this is first test job."

deploy-first-job:
    stage: deploy
    script:
        - echo "this is deploy first job."
Run your first GitLab CI CD pipeline [2 Steps] 3

For ex: Above picture in that code shows four jobs: stages, build-my-first-job, test-my-first-job and deploy-first-job. The comments listed in the echo commands are displayed in the UI when you view the jobs.

Click on Commit changes.

After that you get “the file has been successfully created” message.

Run your first GitLab CI CD pipeline [2 Steps] 4

When you create and specify in the .gitlab-ci.yml file then the pipeline starts and runs the jobs.

Step #3:To check the status of your pipeline and jobs.

Go to Project -> build -> pipelines.

Run your first GitLab CI CD pipeline [2 Steps] 5

A pipeline with three stages should be displayed:

View a visual representation of your pipeline by selecting the pipeline ID.

Run your first GitLab CI CD pipeline [2 Steps] 6

View details of a job by selecting the job name. you can see deploy-first-job.

Run your first GitLab CI CD pipeline [2 Steps] 7

Important point: If you want to edit your .gitlab-ci.yml file then you can use pipeline editor.

Run your first GitLab CI CD pipeline [2 Steps] 8

How to delete .gitlab-ci.yml file?

Go to specific project -> repository -> Click on yaml file which you want to delete.

Run your first GitLab CI CD pipeline [2 Steps] 9

Click on delete.

Run your first GitLab CI CD pipeline [2 Steps] 10

After click on file delete, you will get ‘The file has been successfully deleted’ message.

Run your first GitLab CI CD pipeline [2 Steps] 11

In this article we have covered How to Create and run your first GitLab CI CD pipeline, check available runner, create .gitlab-ci.yml file, check the status of your pipeline and jobs, edit yaml file and delete .gitlab-ci.yml file.

Related Articles:

How to Create a New Project in GitLab [2 Steps]

Reference:

Create and run your first GitLab CI/CD pipeline GitLab Official Page

FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap