Wednesday, January 26, 2022

GitLab-Runner and CICD Pipe line

Install Gitlab Runner on Ubuntu

1. GoTo

2. curl -L "" | sudo bash

3. sudo apt-get install gitlab-runner

4. apt-cache madison gitlab-runner

Register GitLab Runner

1. Create a GitLab Repository java-maven

2. Goto Setting ---> CICD-->Runner ---> Copy URL and Token

3. sudo gitlab-runner register

   Enter URL 

   ENTER Token

   ENTER Description :- gitlab-runner

   Enter Tag :- gitlab-runner

   Enter Executor :- shell

4. gitlab-runner -version

5. Add SSH keys using ssh-keygen 

Add Below CI/CD Pipeline

Example -1

    - gitlab-runner
    - echo "Hello World"

Example 2

stages:          # List of stages for jobs, and their order of execution
  - build
  - test
  - deploy

build-job:       # This job runs in the build stage, which runs first.
  stage: build
    - gitlab-runner
    - echo "Compiling the code..."
    - echo "Compile complete."
    - cd /home/ubuntu/java-maven
    - mvn package

unit-test-job:   # This job runs in the test stage.
  stage: test    # It only starts when the job in the build stage completes successfully.
    - echo "Running unit tests... This will take about 60 seconds."
    - sleep 60
    - echo "Code coverage is 90%"

lint-test-job:   # This job also runs in the test stage.
  stage: test    # It can run at the same time as unit-test-job (in parallel).
    - echo "Linting code... This will take about 10 seconds."
    - sleep 10
    - echo "No lint issues found."

deploy-job:      # This job runs in the deploy stage.
  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
    - echo "Deploying application..."
    - echo "Application successfully deployed."



Post a Comment