I am trying to execute a script based on the result of a particular stage in a Jenkins declarative pipeline, but the post block seems to be dependent on the status of the entire pipeline. Any way of doing this?


pipeline {
     //results in unstable
        //successful stage execution
         success {
          script { 
            // never executes since the pipeline status is unstable
            // how can I get here since the stage was successful?

here are the docs, in case I missed it: https://www.jenkins.io/doc/book/pipeline/syntax/#post

copied from SO: https://stackoverflow.com/questions/66657023/can-you-limit-the-scope-of-the-post-block-in-jenkins-to-the-stage-result-statu

  • my understanding is that if there is a node you can run a script in the post. – Bruce Becker Mar 16 at 16:15
  • @BruceBecker thanks. I am able to run the post if I add a unstable block- I just want to execute it when the stage is status is success independently of the pipeline status. – Sergio Mar 16 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.