Followers

Gitlab - Configure and Register Local Runner On Ubuntu

  Local Gitlab Runner:- If you want to run CICD pipeline from your local shell then we use local runner and it is running on your local mach...

 Local Gitlab Runner:- If you want to run CICD pipeline from your local shell then we use local runner and it is running on your local machine. You can refer to a git lab repo and execute the pipeline from your local runner.Here it is not required to validate the account because you are using your local machine for running CICD pipeline

Once Local runner is installed then you need to register it on local machine and need to provide some details like gitlab url,token,tags to connect to a particular project.

Install local gitlab runner on Ubuntu 18.04 

Step1: Refer below link for latest way to download and install gitlab runner on your local machine

 https://docs.gitlab.com/runner/install/linux-repository.html

Step2:-

curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash

Step3:- Install GitLab runner

          sudo apt install docker.io -y

          sudo apt-get install gitlab-runner

Step4:- Verify gitabrunner is installed

        gitlab-runner -v

Step5: Register gitlab runner to local machine

                sudo gitlab-runner register


Enter the GitLab instance URL (for example, https://gitlab.com/):

https://gitlab.com/

Enter the registration token:

Token from your gitlab runner 

Enter a description for the runner:

 localmachine runner

Enter tags for the runner (comma-separated):

localrunner,localshell

Registering runner... succeeded                     runner=1T_UqosD

Enter an executor: ssh, virtualbox, docker, docker-ssh, parallels, docker-ssh+machine, kubernetes, custom, shell, docker+machine:

shell


Step6:- To verify that local runner is  registered successfully, you need to goto gitlab Project ---> Select Settings---> CICD---> Runner.

When you expand Runner section you will find under "Available Specific Runner" section.

Step7:- Let's update .gitlab-ci.yml file to check that CICD pipeline is running on the local machine or not.

job-to-run:
  tags:
    - localrunner  
    - localshell
  script:
    echo "Hello world"

Step 8:- Once you execute above script then you will find in the log that this pipeline was executed on the local machine.

Step 9: - When you install gitlab runner then a user get create gitlab-runner and it should have sudo permission to run a pipeline.

             vi /etc/sudoers

 and add below entry after root user info and save your file

          gitlab-runner ALL=(ALL) NOPASSWD: ALL

Example:

stages:
  - build
  - test
  - deploy
build:
    stage: build
    tags:
        - localrunner  
        - localshell
    script: 
        - echo "Build Stage"
test:
    stage: test
    tags:
        - localrunner  
        - localshell
    script:
        - echo "Test Stage"        
deploy:
    stage: deploy
    tags:
        - localrunner  
        - localshell
    script:
        - echo "Deploy Stage" 

CICD pipeline with maven junit test

stages:
  - build
  - test
  - deploy

build:
    stage: build
    tags:
        - localrunner  
        - localshell
    script: 
        - cd /home/vagrant/mvnrepo
        - sudo mvn clean package

maven-build:
    stage: build
    tags:
        - localrunner  
        - localshell
    script: 
        - cd /home/vagrant/mvnrepo
        - sudo mvn clean package
    artifacts:
     paths:
      - target/surefire-reports/TEST-*.xml
     reports:
      junit:
        - target/surefire-reports/TEST-*.xml
test:
    stage: test
    tags:
        - localrunner  
        - localshell
    script:
        - sudo ls /home/vagrant/mvnrepo/target/*.jar    
newtest:
    stage: test
    tags:
        - localrunner  
        - localshell
    script:
        - sudo touch /home/vagrant/mvnrepo/passtest    
deploy:
    stage: deploy
    tags:
        - localrunner  
        - localshell
    script:
        - cd /home/vagrant/mvnrepo
        - sudo java -cp target/myproj-1.0-SNAPSHOT.jar com.raman.App

Assignment:- 

Write a CICD pipeline that will be executed on your local machine and it will install apache on your local system.


job-to-run:
  tags:
    - localrunner  
    - localshell
  script:
    - sudo apt update
    - sudo apt install apache2 -y


To verify that apache is installed on your local system run below command

systemctl status apache2








COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Gitlab - Configure and Register Local Runner On Ubuntu
Gitlab - Configure and Register Local Runner On Ubuntu
DevOpsWorld
https://www.devopsworld.co.in/2022/02/gitlab-configure-and-register-local.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/02/gitlab-configure-and-register-local.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content