Install Gitlab Runner on Ubuntu 1. GoTo https://docs.gitlab.com/runner/install/linux-repository.html 2. curl -L "https://packages.gitla...
Install Gitlab Runner on Ubuntu
1. GoTo https://docs.gitlab.com/runner/install/linux-repository.html
2. curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | 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
demo_job_1: tags: - gitlab-runner script: - 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 tags: - gitlab-runner script: - 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. script: - 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). script: - 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. script: - echo "Deploying application..." - echo "Application successfully deployed."
COMMENTS