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() }
}
All CI/CD questions

More on Jenkins