Creating “Hello World” CI/CD Pipeline on Gitlab for testers.
- Register free account at https://gitlab.com/users/sign_up OR sign into your existing account.
- Create new project (new repo) in the https://gitlab.com homepage.
- If your account is not set up locally, you might have to run following commands.
$ git config –-global user.email “[email address]”
$ git config –-global user.name “[your name]”
Also create a Personal Access Token at Gitlab and use it as password for your user account when promoted for password.
4. Copy the project URL and clone it locally.
$ git clone <your_project_URL> in your terminal (CLI)
5. Now, you can add the the CI/CD Pipeline yam file named ‘.gitlab-ci.yml’ as shown below in the top folder level.
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
script:
- echo "Compiling the code..."
- echo "Compile complete."
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."
6. Check-in the file from the git CLI terminal by giving following commands.
$ git status
$git add .
$git commit -m “adding gitlab CI/CD for the first time”
$git push
7. Now you can see the the CI/CD pipeline working under the project as shown below.
Congrats you made your first hello world Gitlab Pipeline.