Complete the code to define a stage named 'Build' in a Jenkins pipeline.
stage('[1]') { steps { echo 'Building the project' } }
The stage block defines a stage in the Jenkins pipeline. Here, the stage is named 'Build'.
Complete the code to add a shell command step that prints 'Hello World' inside a stage.
stage('Example') { steps { [1] 'echo Hello World' } }
bat on a Linux agent.echo as a step instead of a command.The sh step runs shell commands on Unix-like agents in Jenkins pipelines.
Fix the error in the pipeline code by completing the missing keyword to define multiple stages.
pipeline {
agent any
[1] {
stage('Build') {
steps { echo 'Building' }
}
stage('Test') {
steps { echo 'Testing' }
}
}
}steps instead of stages to group stages.stages block entirely.The stages block groups multiple stage blocks inside a Jenkins pipeline.
Fill both blanks to create a stage named 'Deploy' that runs a shell command to deploy the app.
stage('[1]') { steps { [2] 'deploy.sh' } }
bat on a Linux agent.The stage is named 'Deploy' and uses the sh step to run the shell script deploy.sh.
Fill all three blanks to define a pipeline with an agent, stages block, and a stage named 'Test' that echoes a message.
pipeline {
agent [1]
[2] {
stage('[3]') {
steps {
echo 'Running tests'
}
}
}
}steps instead of stages to group stages.The pipeline uses agent any to run on any available agent, the stages block to group stages, and defines a stage named 'Test'.