Bird
Raised Fist0
Jenkinsdevops~20 mins

GitLab CI comparison in Jenkins - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
GitLab CI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Key difference between GitLab CI and Jenkins pipelines

Which statement best describes a key difference between GitLab CI and Jenkins pipelines?

AJenkins pipelines cannot be version controlled, but GitLab CI pipelines are stored in a database only.
BGitLab CI requires a separate server installation, while Jenkins is fully cloud-based with no server setup.
CGitLab CI uses a YAML file stored in the repository to define pipelines, while Jenkins uses a separate Jenkinsfile or UI configuration.
DJenkins pipelines are only triggered manually, whereas GitLab CI pipelines run only on schedule.
Attempts:
2 left
💡 Hint

Think about where the pipeline configuration files live and how they are managed.

💻 Command Output
intermediate
2:00remaining
Output of Jenkins pipeline stage status

Given this Jenkins pipeline snippet, what will be the output status of the Build stage if the sh command fails?

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        sh 'exit 1'
      }
    }
  }
}
AThe Build stage will be marked as FAILED and the pipeline will stop.
BThe Build stage will be marked as SUCCESS despite the failure.
CThe Build stage will be marked as UNSTABLE and pipeline continues.
DThe pipeline will ignore the failure and mark the Build stage as SKIPPED.
Attempts:
2 left
💡 Hint

Consider how Jenkins treats shell command exit codes in pipeline steps.

🔀 Workflow
advanced
2:00remaining
Order of GitLab CI pipeline stages execution

What is the correct order of execution for the following GitLab CI stages defined in .gitlab-ci.yml?

A2,1,3,4
B1,2,3,4
C2,3,1,4
D3,2,1,4
Attempts:
2 left
💡 Hint

Remember the typical order of stages in CI/CD pipelines.

❓ Troubleshoot
advanced
2:00remaining
Why does Jenkins pipeline fail to trigger on Git push?

A Jenkins pipeline is not triggering automatically when code is pushed to the Git repository. What is the most likely cause?

AThe Jenkins agent is offline but triggers still run pipelines.
BThe Jenkinsfile syntax is invalid causing the pipeline to skip triggers.
CThe Git repository is private and Jenkins cannot clone it manually.
DThe Jenkins webhook is not configured or not reachable by the Git server.
Attempts:
2 left
💡 Hint

Think about how Jenkins knows when to start a pipeline on Git events.

✅ Best Practice
expert
2:00remaining
Best practice for secret management in GitLab CI vs Jenkins

Which approach is considered best practice for managing secrets securely in GitLab CI compared to Jenkins?

AUse environment variables set manually on build agents without any encryption or masking.
BUse GitLab CI's built-in masked variables and Jenkins credentials plugin to avoid storing secrets in code.
CCommit encrypted secrets files to the repository and decrypt during pipeline execution without external tools.
DStore secrets directly in the pipeline YAML or Jenkinsfile for easy access during builds.
Attempts:
2 left
💡 Hint

Consider how each tool supports secret masking and secure storage.

Practice

(1/5)
1. Which statement best describes the main difference between Jenkins and GitLab CI?
easy
A. Jenkins cannot automate building and testing.
B. GitLab CI has more plugins than Jenkins.
C. GitLab CI is easier to start with if you already use GitLab for your code.
D. Jenkins is only for deployment, not for testing.

Solution

  1. Step 1: Understand GitLab CI's integration

    GitLab CI is built into GitLab, making it simpler to start if your code is hosted there.
  2. Step 2: Compare Jenkins capabilities

    Jenkins offers more flexibility and plugins but requires more setup.
  3. Final Answer:

    GitLab CI is easier to start with if you already use GitLab for your code. -> Option C
  4. Quick Check:

    GitLab CI simpler start = B [OK]
Hint: GitLab CI is simpler if your code is on GitLab [OK]
Common Mistakes:
  • Thinking Jenkins cannot automate testing
  • Assuming GitLab CI has more plugins
  • Believing Jenkins is only for deployment
2. Which of the following is the correct way to define a simple Jenkins pipeline step that echoes 'Hello World'?
easy
A. pipeline { stages { stage('Example') { steps { echo 'Hello World' } } } }
B. pipeline { steps { stage('Example') { echo 'Hello World' } } }
C. pipeline { stage('Example') { steps { print('Hello World') } } }
D. pipeline { stages { step('Example') { echo 'Hello World' } } }

Solution

  1. Step 1: Recall Jenkins pipeline syntax

    A Jenkins pipeline requires 'stages' containing 'stage' blocks, each with 'steps'. The echo command is inside steps.
  2. Step 2: Identify correct syntax

    pipeline { stages { stage('Example') { steps { echo 'Hello World' } } } } correctly nests stages, stage, steps, and uses echo properly.
  3. Final Answer:

    pipeline { stages { stage('Example') { steps { echo 'Hello World' } } } } -> Option A
  4. Quick Check:

    Correct Jenkins pipeline syntax = A [OK]
Hint: Remember stages > stage > steps > commands in Jenkins pipeline [OK]
Common Mistakes:
  • Placing steps outside stage
  • Using print instead of echo
  • Misnaming stage as step
3. Given this Jenkins pipeline snippet, what will be the output in the console?
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
    stage('Test') {
      steps {
        echo 'Testing...'
      }
    }
  }
}
medium
A. Build stage skipped, only Testing runs
B. Building...\nTesting...
C. Testing...\nBuilding...
D. Syntax error, pipeline fails

Solution

  1. Step 1: Analyze pipeline stages order

    The pipeline runs stages in order: first 'Build', then 'Test'. Each stage echoes its message.
  2. Step 2: Determine console output

    The console will show 'Building...' first, then 'Testing...'.
  3. Final Answer:

    Building...\nTesting... -> Option B
  4. Quick Check:

    Stages run sequentially = C [OK]
Hint: Jenkins stages run in order, echo outputs in sequence [OK]
Common Mistakes:
  • Assuming stages run in parallel by default
  • Mixing order of outputs
  • Thinking pipeline syntax is invalid
4. You have this Jenkins pipeline snippet:
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
    stage('Test') {
      step {
        echo 'Testing...'
      }
    }
  }
}
What is the problem with this pipeline?
medium
A. The 'Test' stage uses 'step' instead of 'steps', causing a syntax error.
B. The 'Build' stage is missing an agent.
C. The echo command is invalid in Jenkins pipelines.
D. Stages must be defined outside the pipeline block.

Solution

  1. Step 1: Check stage syntax

    Each stage must have a 'steps' block, not 'step'. The 'Test' stage incorrectly uses 'step'.
  2. Step 2: Understand Jenkins syntax rules

    This causes a syntax error because Jenkins expects 'steps' to group commands.
  3. Final Answer:

    The 'Test' stage uses 'step' instead of 'steps', causing a syntax error. -> Option A
  4. Quick Check:

    Use 'steps' block in stages = A [OK]
Hint: Stages require 'steps' block, not 'step' [OK]
Common Mistakes:
  • Confusing 'step' and 'steps'
  • Thinking echo is invalid
  • Misplacing stages outside pipeline
5. You want to migrate a simple GitLab CI pipeline to Jenkins. The GitLab CI YAML is:
stages:
  - build
  - test

build_job:
  stage: build
  script:
    - echo "Building..."

test_job:
  stage: test
  script:
    - echo "Testing..."
Which Jenkins pipeline best replicates this behavior?
hard
A. pipeline { agent any stages { stage('build') { steps { print('Building...') } } stage('test') { steps { print('Testing...') } } } }
B. pipeline { agent any steps { echo 'Building...' echo 'Testing...' } }
C. pipeline { agent any stages { stage('build') { step { echo 'Building...' } } stage('test') { step { echo 'Testing...' } } } }
D. pipeline { agent any stages { stage('build') { steps { echo 'Building...' } } stage('test') { steps { echo 'Testing...' } } } }

Solution

  1. Step 1: Map GitLab stages to Jenkins stages

    GitLab stages 'build' and 'test' correspond to Jenkins stages named 'build' and 'test'.
  2. Step 2: Use correct Jenkins syntax

    Each stage must have a 'steps' block with echo commands to replicate the script commands.
  3. Final Answer:

    Jenkins pipeline with stages 'build' and 'test' each having steps with echo commands. -> Option D
  4. Quick Check:

    Match GitLab stages with Jenkins stages and steps = D [OK]
Hint: Translate GitLab stages to Jenkins stages with steps and echo [OK]
Common Mistakes:
  • Using 'step' instead of 'steps'
  • Using print instead of echo
  • Putting all commands in one steps block without stages
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard