0
0
Gitdevops~20 mins

GitLab CI basics - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GitLab CI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this GitLab CI pipeline status command?
You run the command gitlab-runner status on a machine where GitLab Runner is installed and registered. What output do you expect if the runner is active and connected?
Git
gitlab-runner status
AGitLab Runner: paused
B
Runtime platform: linux/amd64

GitLab Runner: stopped
CError: command not found
D
Runtime platform: linux/amd64

GitLab Runner: running
Attempts:
2 left
💡 Hint
Think about what the status command shows when the runner is working.
Configuration
intermediate
2:00remaining
Which .gitlab-ci.yml snippet correctly defines a job that runs only on the master branch?
You want a job named deploy to run only when commits are pushed to the master branch. Which snippet achieves this?
A
deploy:
  script:
    - echo Deploying...
  only:
    - master
B
deploy:
  script:
    - echo Deploying...
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop"'
C
deploy:
  script:
    - echo Deploying...
  except:
    - master
D
deploy:
  script:
    - echo Deploying...
  when: manual
Attempts:
2 left
💡 Hint
Look for the keyword that specifies branches to include.
🔀 Workflow
advanced
2:00remaining
What is the correct order of stages in this GitLab CI pipeline configuration?
Given this snippet, what is the order in which jobs run?

stages:
  - build
  - test
  - deploy

build_job:
  stage: build
  script: echo Building

test_job:
  stage: test
  script: echo Testing

deploy_job:
  stage: deploy
  script: echo Deploying
A1,2,3
B3,2,1
C2,1,3
D1,3,2
Attempts:
2 left
💡 Hint
Jobs run in the order of stages defined at the top.
Troubleshoot
advanced
2:00remaining
Why does this GitLab CI job fail with 'script not found' error?
This job fails with an error saying the script is not found:

job1:
  script:
    - ./deploy.sh

The deploy.sh file exists in the repository root. What is the most likely cause?
AThe <code>script</code> keyword is misspelled in the YAML file.
BGitLab CI does not support running shell scripts.
CThe <code>deploy.sh</code> file is not executable or missing execute permission.
DThe job name <code>job1</code> is invalid.
Attempts:
2 left
💡 Hint
Check file permissions for scripts in CI jobs.
Best Practice
expert
2:00remaining
Which GitLab CI configuration snippet correctly caches dependencies to speed up pipeline runs?
You want to cache the node_modules folder between pipeline runs to avoid reinstalling packages every time. Which snippet correctly configures caching?
A
cache:
  paths:
    - node_modules/
B
cache:
  key: "node_modules"
  paths:
    - node_modules/
C
cache:
  paths:
    - node_modules
  when: always
D
cache:
  paths:
    - node_modules
  policy: push
Attempts:
2 left
💡 Hint
Caching often requires a key to identify cache versions.