0
0
Gitdevops~30 mins

GitLab CI basics - Mini Project: Build & Apply

Choose your learning style9 modes available
GitLab CI basics
📖 Scenario: You are working on a small project and want to automate testing using GitLab CI. You will create a simple GitLab CI configuration file to run a test job automatically when you push code.
🎯 Goal: Build a basic .gitlab-ci.yml file that defines a job named test which runs a simple shell command echo "Running tests...".
📋 What You'll Learn
Create a .gitlab-ci.yml file with a job named test
The test job must run the command echo "Running tests..."
Use the script keyword to define the command
Ensure the job runs in the test stage
💡 Why This Matters
🌍 Real World
GitLab CI is used to automate testing and deployment in software projects, saving time and reducing errors.
💼 Career
Understanding GitLab CI basics is essential for DevOps roles and developers working with continuous integration pipelines.
Progress0 / 4 steps
1
Create the basic GitLab CI file
Create a file named .gitlab-ci.yml and add the line stages: with a list containing test to define the stages.
Git
Need a hint?

Use YAML syntax to define stages: followed by a list with - test.

2
Add the test job
Add a job named test that runs in the test stage. Use the stage keyword with value test.
Git
Need a hint?

Define a job by writing its name followed by stage: test.

3
Add the script to run
Inside the test job, add a script section that runs the command echo "Running tests...".
Git
Need a hint?

Use script: followed by a list with the echo command.

4
Check the job output
Run the GitLab CI pipeline and verify that the output contains the text Running tests.... Write a command to simulate this by printing Running tests....
Git
Need a hint?

Use echo "Running tests..." to show the output.