Pipeline post action should support conditions

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Hello,

      Would be nice to add a when conditions to pipeline post actions. Here is an example:

      pipeline {
          agent any;
          stages { ... }
          // run only for master branch
          post {
              when { branch 'master' }
              failure {
                  // send slack notification about failure build
              }
          }
          // run without any additional conditions (it works now)
          post {
              success { ... }
              cleanup { ... }
          }
      }
      

      I don't have a good idea how to implement this without breaking-changes. In this example
      there is an idea that we can add multiple pipeline post blocks (one for every when condition)

      Motivation:
      I would like to send notification about failed builds, but only for releases braches. We don't want to receive notifications about failed pull requests builds.

            Assignee:
            Andrew Bayer
            Reporter:
            Kamil Grabowski
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: