Bird
Raised Fist0
Jenkinsdevops~10 mins

CI/CD tools landscape in Jenkins - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a Jenkins pipeline stage named 'Build'.

Jenkins
stage('[1]') {
    steps {
        echo 'Building the project'
    }
}
Drag options to blanks, or click blank then click option'
ABuild
BTest
CDeploy
DClean
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong stage name like 'Test' when the step is building.
Leaving the stage name empty.
2fill in blank
medium

Complete the code to trigger the pipeline only when changes are pushed to the 'main' branch.

Jenkins
pipeline {
    agent any
    triggers {
        [1] {
            pollSCM('H/5 * * * *')
        }
    }
    stages {
        stage('Build') {
            steps {
                echo 'Building...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
ApollSCM
Bbranch
Ccron
DgithubPush
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cron' which triggers on a schedule, not on code changes.
Using 'branch' which is not a valid trigger keyword.
3fill in blank
hard

Fix the error in the Jenkinsfile snippet to correctly checkout code from Git.

Jenkins
pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps {
                [1]([$class: 'GitSCM', branches: [[name: '*/main']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Aclone
Bcheckout
CgitClone
DgitCheckout
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gitCheckout' which is not a valid Jenkins step.
Using 'clone' which is a git command but not a Jenkins pipeline step.
4fill in blank
hard

Fill both blanks to create a post-build action that always sends an email notification.

Jenkins
post {
    [1] {
        mail to: 'team@example.com', subject: 'Build [2]', body: 'The build has finished.'
    }
}
Drag options to blanks, or click blank then click option'
Aalways
Bsuccess
Cfailure
Dunstable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'success' which only runs on successful builds.
Using 'failure' which only runs on failed builds.
5fill in blank
hard

Fill all three blanks to define an environment variable and use it in a shell step.

Jenkins
pipeline {
    agent any
    environment {
        [1] = '[2]'
    }
    stages {
        stage('Print Env') {
            steps {
                sh 'echo [3]'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
AMY_VAR
BHelloWorld
C$MY_VAR
DGREETING
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable name with lowercase letters.
Not using '$' to reference the variable in shell.

Practice

(1/5)
1. What is the main purpose of CI/CD tools like Jenkins in software development?
easy
A. To design user interfaces
B. To write code manually
C. To automate building, testing, and deploying software
D. To manage hardware resources

Solution

  1. Step 1: Understand CI/CD tools role

    CI/CD tools automate repetitive tasks in software development like building, testing, and deploying.
  2. Step 2: Compare options

    Options B, C, and D describe unrelated tasks. Only To automate building, testing, and deploying software matches the automation purpose.
  3. Final Answer:

    To automate building, testing, and deploying software -> Option C
  4. Quick Check:

    CI/CD tools automate software delivery = A [OK]
Hint: CI/CD tools automate software delivery steps [OK]
Common Mistakes:
  • Confusing CI/CD tools with coding or design tools
  • Thinking CI/CD tools manage hardware
  • Assuming CI/CD tools replace developers
2. Which of the following is the correct way to define a stage in a Jenkins pipeline?
easy
A. stage('Build') { steps { echo 'Building...' } }
B. step('Build') { echo 'Building...' }
C. stage: Build { echo 'Building...' }
D. buildStage { echo 'Building...' }

Solution

  1. Step 1: Recall Jenkins pipeline syntax

    Jenkins uses stage('name') { steps { ... } } to define stages.
  2. Step 2: Check options for correct syntax

    Only stage('Build') { steps { echo 'Building...' } } matches the correct syntax with stage and steps blocks.
  3. Final Answer:

    <code>stage('Build') { steps { echo 'Building...' } }</code> -> Option A
  4. Quick Check:

    Correct Jenkins stage syntax = C [OK]
Hint: Stages use stage('name') with steps block [OK]
Common Mistakes:
  • Using 'step' instead of 'stage'
  • Missing the steps block inside stage
  • Incorrect block syntax with colons or missing braces
3. Given this Jenkins pipeline snippet, what will be printed during the 'Test' stage?
pipeline {
  agent any
  stages {
    stage('Build') {
      steps { echo 'Building...' }
    }
    stage('Test') {
      steps { echo 'Testing...' }
    }
  }
}
medium
A. Testing... Building...
B. Testing...
C. Building...
D. Building... Testing...

Solution

  1. Step 1: Understand pipeline stage order

    The pipeline runs stages in order: 'Build' then 'Test'.
  2. Step 2: Identify echo outputs

    'Build' stage prints 'Building...', 'Test' stage prints 'Testing...'. Both run sequentially.
  3. Final Answer:

    Building... Testing... -> Option D
  4. Quick Check:

    Stages run in order, print messages in sequence = B [OK]
Hint: Stages run sequentially, outputs print in order [OK]
Common Mistakes:
  • Assuming stages run in parallel by default
  • Mixing output order
  • Ignoring all stages run unless skipped
4. Identify the error in this Jenkins pipeline snippet:
pipeline {
  agent any
  stages {
    stage('Deploy') {
      step { echo 'Deploying...' }
    }
  }
}
medium
A. The keyword should be 'steps' not 'step'
B. Missing agent declaration
C. Stage name must be lowercase
D. Echo command is invalid

Solution

  1. Step 1: Check pipeline syntax for stages

    Inside a stage, the correct block is steps (plural), not step.
  2. Step 2: Verify other parts

    Agent is declared, stage name case is allowed, echo is valid. Only 'step' is wrong.
  3. Final Answer:

    The keyword should be 'steps' not 'step' -> Option A
  4. Quick Check:

    Use 'steps' block inside stage = A [OK]
Hint: Inside stage use 'steps' plural block [OK]
Common Mistakes:
  • Using 'step' instead of 'steps'
  • Thinking stage names must be lowercase
  • Assuming echo is not allowed
5. You want to create a Jenkins pipeline that builds, tests, and deploys only if tests pass. Which approach best fits this CI/CD workflow?
hard
A. Skip Test stage and deploy immediately after Build
B. Define sequential stages: Build, Test, Deploy; Deploy runs only if Test succeeds
C. Deploy first, then Build and Test in any order
D. Run Build and Deploy stages in parallel, then Test last

Solution

  1. Step 1: Understand CI/CD workflow logic

    Tests must pass before deploying to avoid broken releases.
  2. Step 2: Choose pipeline structure

    Sequential stages Build -> Test -> Deploy ensure deploy runs only if tests succeed.
  3. Step 3: Evaluate other options

    Parallel or skipping tests risks deploying broken code; deploying first is illogical.
  4. Final Answer:

    Define sequential stages: Build, Test, Deploy; Deploy runs only if Test succeeds -> Option B
  5. Quick Check:

    Sequential stages with test gate = D [OK]
Hint: Deploy only after successful tests in sequence [OK]
Common Mistakes:
  • Running deploy before tests
  • Skipping tests to save time
  • Running build and deploy in parallel
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