Is it possible to do "success" post build before "always" ?
For exemple, if I do that :
post {
success{
archiveArtifacts artifacts: 'server/target/*.jar'
deleteDir ()
}
always{
deleteDir()
}
}
In console Output it's done upside down...
" [Pipeline] deleteDir
[Pipeline] archiveArtifacts Archiving artifacts "
To bypass that, I use :
success{
archiveArtifacts artifacts: 'server/target/*.jar'
deleteDir ()
}
failure{
deleteDir()
}
aborted{
deleteDir()
}
}
Stage. A stage block defines a conceptually distinct subset of tasks performed through the entire Pipeline (e.g. "Build", "Test" and "Deploy" stages), which is used by many plugins to visualize or present Jenkins Pipeline status/progress.
It contains a group of states called build, deploy, test and release. These events are interlinked with each other. Every state has its events, which work in a sequence called a continuous delivery pipeline.
Basically, declarative and scripted pipelines differ in terms of the programmatic approach. One uses a declarative programming model and the second uses an imperative programming mode. Declarative pipelines break down stages into multiple steps, while in scripted pipelines there is no need for this.
Since the post section of a Pipeline is guaranteed to run at the end of a Pipeline's execution, we can add some notification or other steps to perform finalization, notification, or other end-of-Pipeline tasks.
You can use cleanup stage.
Example: https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/83abd0ec35960c1f2a37b6a66b2d26385b2962e2/pipeline-model-definition/src/test/resources/postChecksAllConditions.groovy
PR: https://github.com/jenkinsci/pipeline-model-definition-plugin/commit/83abd0ec35960c1f2a37b6a66b2d26385b2962e2#diff-136d8ce8670181449534f5b993a87051
No, you cannot change this order. The steps alway run in order: always, changed, success, unstable, failure
https://www.cloudbees.com/sites/default/files/declarative-pipeline-refcard.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With