Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a simple Jenkins pipeline.
Jenkins
pipeline {
agent any
stages {
stage('Build') {
steps {
[1] 'echo Building...'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' instead of 'sh' causes errors.
✗ Incorrect
The sh step runs shell commands in Jenkins pipelines.
2fill in blank
mediumComplete the code to specify the pipeline agent.
Jenkins
pipeline {
agent [1]
stages {
stage('Test') {
steps {
sh 'echo Testing...'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around 'any' causes syntax errors.
✗ Incorrect
The agent any means the pipeline can run on any available agent.
3fill in blank
hardFix the error in the pipeline syntax to run a shell command.
Jenkins
pipeline {
agent any
stages {
stage('Deploy') {
steps {
[1] 'echo Deploying...'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'shell' or 'runShell' causes errors.
✗ Incorrect
The correct Jenkins pipeline step to run shell commands is sh.
4fill in blank
hardFill both blanks to create a stage with a shell step that echoes a message.
Jenkins
pipeline {
agent any
stages {
stage([1]) {
steps {
[2] 'echo Hello World'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using run instead of sh causes errors.
✗ Incorrect
The stage name must be a string like 'Greeting', and the shell step is sh.
5fill in blank
hardFill all three blanks to define a pipeline with an agent, a stage name, and a shell step.
Jenkins
pipeline {
agent [1]
stages {
stage([2]) {
steps {
[3] 'echo Pipeline as Code'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around agent or using wrong shell step.
✗ Incorrect
The agent is any, the stage name is a string 'ExampleStage', and the shell step is sh.