Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a simple Jenkins pipeline stage named 'Build'.
Jenkins
stage('Build') { steps { [1] 'echo Building the project' } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'execute' which are not Jenkins pipeline steps.
✗ Incorrect
The sh step runs shell commands in Jenkins pipeline.
2fill in blank
mediumComplete the code to add a stage named 'Test' that runs a shell command.
Jenkins
stage('Test') { steps { [1] 'echo Running tests' } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Windows-specific steps like 'bat' on Unix agents.
✗ Incorrect
The sh step runs shell commands on Unix-like agents.
3fill in blank
hardFix the error in the pipeline code to correctly define a stage named 'Deploy'.
Jenkins
stage('Deploy') { [1] { sh 'echo Deploying application' } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'script' or 'commands' which are not valid block names here.
✗ Incorrect
The steps block is required inside a stage to define the commands to run.
4fill in blank
hardFill both blanks to create a pipeline with two stages: 'Build' and 'Test', each running a shell command.
Jenkins
pipeline {
agent any
stages {
stage('Build') {
[1] {
sh 'echo Building'
}
}
stage('Test') {
[2] {
sh 'echo Testing'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different or invalid block names like 'script' or 'commands'.
✗ Incorrect
Each stage requires a steps block to define the commands to run.
5fill in blank
hardFill all three blanks to create a pipeline with stages 'Build', 'Test', and 'Deploy', each running a shell command.
Jenkins
pipeline {
agent any
stages {
stage('Build') {
[1] {
sh 'echo Build started'
}
}
stage('Test') {
[2] {
sh 'echo Test started'
}
}
stage('Deploy') {
[3] {
sh 'echo Deploy started'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different block names for different stages.
✗ Incorrect
All stages require the steps block to define the commands to run.