Complete the code to define a Jenkins pipeline stage named 'Build'.
stage('[1]') { steps { echo 'Building the project' } }
The stage name should be 'Build' to represent the build step in the pipeline.
Complete the code to specify the agent for the pipeline to run on any available node.
pipeline {
agent [1]
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}The 'any' agent tells Jenkins to run the pipeline on any available node.
Fix the error in the stage declaration to correctly name the 'Deploy to Staging' stage.
stage([1]) { steps { echo 'Deploying to staging environment' } }
Stage names must be strings enclosed in quotes. Single quotes are standard.
Fill both blanks to create a conditional step that deploys only if the branch is 'staging'.
stage('Deploy') { when { expression { BRANCH_NAME [1] '[2]' } } steps { echo 'Deploying to staging environment' } }
!= or wrong branch names.The 'when' condition uses expression { BRANCH_NAME == 'staging' } to check if the branch is 'staging'.
Fill all three blanks to define a pipeline with stages for dev, staging, and prod deployments.
pipeline {
agent any
stages {
stage('[1]') {
steps {
echo 'Deploying to development environment'
}
}
stage('[2]') {
steps {
echo 'Deploying to staging environment'
}
}
stage('[3]') {
steps {
echo 'Deploying to production environment'
}
}
}
}The stages should be named 'dev', 'staging', and 'prod' to represent the deployment environments.