0
0
Jenkinsdevops~10 mins

Pipeline stages and steps in Jenkins - Interactive Code Practice

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

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

Jenkins
stage('[1]') {
    steps {
        echo 'Building the project'
    }
}
Drag options to blanks, or click blank then click option'
AInit
BBuild
CDeploy
DTest
Attempts:
3 left
💡 Hint
Common Mistakes
Using a step name instead of a stage name.
Leaving the stage name empty.
2fill in blank
medium

Complete the code to add a shell command step that prints 'Hello World' inside a stage.

Jenkins
stage('Example') {
    steps {
        [1] 'echo Hello World'
    }
}
Drag options to blanks, or click blank then click option'
Ash
Becho
Cscript
Dbat
Attempts:
3 left
💡 Hint
Common Mistakes
Using bat on a Linux agent.
Using echo as a step instead of a command.
3fill in blank
hard

Fix the error in the pipeline code by completing the missing keyword to define multiple stages.

Jenkins
pipeline {
    agent any
    [1] {
        stage('Build') {
            steps { echo 'Building' }
        }
        stage('Test') {
            steps { echo 'Testing' }
        }
    }
}
Drag options to blanks, or click blank then click option'
Astages
Bsteps
Cscript
Denvironment
Attempts:
3 left
💡 Hint
Common Mistakes
Using steps instead of stages to group stages.
Omitting the stages block entirely.
4fill in blank
hard

Fill both blanks to create a stage named 'Deploy' that runs a shell command to deploy the app.

Jenkins
stage('[1]') {
    steps {
        [2] 'deploy.sh'
    }
}
Drag options to blanks, or click blank then click option'
ADeploy
BBuild
Csh
Dbat
Attempts:
3 left
💡 Hint
Common Mistakes
Using bat on a Linux agent.
Naming the stage incorrectly.
5fill in blank
hard

Fill all three blanks to define a pipeline with an agent, stages block, and a stage named 'Test' that echoes a message.

Jenkins
pipeline {
    agent [1]
    [2] {
        stage('[3]') {
            steps {
                echo 'Running tests'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Aany
Bstages
CTest
Dsteps
Attempts:
3 left
💡 Hint
Common Mistakes
Using steps instead of stages to group stages.
Incorrect agent specification.