What does the `post` section in a declarative pipeline do?
BeginnerConceptJenkins
Answer
post defines actions that run after the stages (or a stage) based on the result. Conditions include always, success, failure, unstable, changed, fixed, regression, aborted and cleanup. Typical uses: publish test reports, send Slack/email notifications, archive logs, and clean the workspace. cleanup runs last, after every other post condition.
post {
always { junit '**/target/surefire-reports/*.xml' }
failure { slackSend channel: '#ci', message: "FAILED ${env.JOB_NAME} #${env.BUILD_NUMBER}" }
cleanup { cleanWs() }
}
More on Jenkins
What is Jenkins and how is its architecture organised?BeginnerWhat are executors, nodes and labels in Jenkins?IntermediateWhy should you not run builds on the Jenkins controller?BeginnerHow do inbound (JNLP/WebSocket) and SSH agents connect to the controller?IntermediateWhat is a Jenkinsfile and where does it live?BeginnerDeclarative versus Scripted Pipeline: what are the differences?Intermediate