Complete the code to define a rollback stage in a Jenkins pipeline.
stage('Rollback') { steps { sh '[1]' } }
The rollback stage runs the rollback.sh script to revert changes.
Complete the code to trigger rollback only if the deployment fails.
post {
failure {
script {
[1]()
}
}
}The rollback() function is called when the deployment fails to revert changes.
Fix the error in the rollback script call to use the correct Jenkins syntax.
steps {
[1] 'rollback.sh'
}Jenkins uses sh to run shell scripts in pipeline steps.
Fill both blanks to define a rollback stage that runs a shell script and echoes a message.
stage('Rollback') { steps { [1] 'rollback.sh' [2] 'Rollback completed successfully' } }
The sh step runs the rollback script, and echo prints a message.
Fill all three blanks to create a rollback stage that runs a script, checks a condition, and echoes a message.
stage('Rollback') { steps { [1] 'rollback.sh' script { if (currentBuild.result == '[2]') { [3] 'Rollback was successful' } } } }
The rollback script runs with sh. The condition checks if the build result is FAILURE. Then echo prints a success message.