Complete the code to define a Jenkins pipeline stage named 'Build'.
stage('[1]') { steps { echo 'Building the project' } }
The stage block defines a pipeline stage. Here, the stage is named 'Build' to represent the build step.
Complete the code to run a shell command in the Jenkins pipeline.
steps {
[1] 'mvn clean install'
}bat on Linux agents causing errors.The sh step runs shell commands on Unix/Linux agents. Here, it runs the Maven build command.
Fix the error in the Jenkins pipeline syntax to declare an agent.
pipeline {
agent {
[1] 'linux'
}
stages {
stage('Test') {
steps {
echo 'Running tests'
}
}
}
}any without braces causes syntax errors here.node with agent syntax.The agent { label 'linux' } block specifies the pipeline runs on agents labeled 'linux'.
Fill both blanks to define a post-build action that always runs and sends a notification.
post {
[1] {
[2] 'Build completed'
}
}success instead of always to run post actions.sh instead of echo for simple messages.The always block runs regardless of build result. The echo step prints a message.
Fill all three blanks to create a parallel stage with two branches named 'UI Tests' and 'API Tests'.
stage('Test') { parallel { '[1]': { steps { [2] 'Running UI tests' } }, '[3]': { steps { echo 'Running API tests' } } } }
sh instead of echo for simple messages.The parallel block runs multiple branches at the same time. Branch names are 'UI Tests' and 'API Tests'. The echo step prints messages.