Complete the code to define a Jenkins pipeline stage that sends feedback after build.
stage('Feedback') { steps { [1] 'echo "Build completed, sending feedback"' } }
input instead of sh for running commands.The sh step runs shell commands, here used to send feedback via echo.
Complete the code to trigger a Jenkins pipeline stage only if the build fails, to send failure feedback.
stage('Failure Feedback') { when { [1] 'FAILURE' } steps { sh 'echo "Build failed, notifying team"' } }
branch or environment which do not check build status.The status condition checks the build result status to trigger the stage.
Fix the error in the Jenkins pipeline snippet to correctly send feedback after tests.
stage('Test Feedback') { steps { [1] 'echo "Tests passed, sending feedback"' } }
bat on Unix agents causes errors.The sh step is used to run shell commands on Unix-like agents, correct for sending feedback.
Fill both blanks to create a post-build action that always sends feedback regardless of build result.
post {
[1] {
[2] 'echo "Build finished, sending feedback"'
}
}success or failure which run conditionally.The always block runs regardless of build result, and sh runs the shell command to send feedback.
Fill all three blanks to define a pipeline that sends feedback only if tests pass and code is on the main branch.
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'run tests'
}
}
stage('Feedback') {
when {
[1] 'SUCCESS'
[2] 'main'
}
steps {
[3] 'echo "Tests passed on main, sending feedback"'
}
}
}
}environment instead of branch for branch condition.The status condition checks for success, branch checks the branch name, and sh runs the feedback command.