Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48692

Support all result types for build steps of postBuildScripts plugin

      When using v1.66 of the job-dsl-plugin the postBuildScripts plugin can be used as follows:

      job {
        publishers {
          postBuildScripts {
            onlyIfBuildSucceeds(true)
            onlyIfBuildFails(true)
            steps {
               ... build steps ...
            }
          }
        }
      }

      The problem is that due to how results are migrated from the old XML style to new (See: https://github.com/jenkinsci/postbuildscript-plugin/blob/9e7a84a29a3b48b93f18606a7eaea22f03f5013a/src/main/java/org/jenkinsci/plugins/postbuildscript/PostBuildScript.java#L143-L152) the only values which can be set are SUCCESS or FAILURE using the job-dsl-plugin

       

      I would like to also run my post build steps if a job is ABORTED for example but there is no API to do this.

          [JENKINS-48692] Support all result types for build steps of postBuildScripts plugin

          Daniel Heid added a comment -

          I implemented the new format into the Job DSL and added a pull request: https://github.com/jenkinsci/job-dsl-plugin/pull/1098

          This is the first step to add new result types. Perhaps you can vote for it?

          Daniel Heid added a comment - I implemented the new format into the Job DSL and added a pull request: https://github.com/jenkinsci/job-dsl-plugin/pull/1098 This is the first step to add new result types. Perhaps you can vote for it?

          You can use the Automatically Generated DSL to use new features:

          job('example') {
            publishers {
              postBuildScript {
                buildSteps {
                  postBuildStep {
                    results(['UNSTABLE', 'FAILURE'])
                    buildSteps {
                      shell {
                        command('echo Hello World')
                      }
                    }
                  }
                }
                markBuildUnstable(false)
              }
            }
          } 
          

          Daniel Spilker added a comment - You can use the Automatically Generated DSL to use new features: job( 'example' ) { publishers { postBuildScript { buildSteps { postBuildStep { results([ 'UNSTABLE' , 'FAILURE' ]) buildSteps { shell { command( 'echo Hello World' ) } } } } markBuildUnstable( false ) } } }

            daspilker Daniel Spilker
            gd185052 G D
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: