It should be possible to claim failed workflow builds.

          [JENKINS-27206] Enable claim support from workflow

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pom.xml
          src/main/java/hudson/plugins/claim/ClaimPublisher.java
          http://jenkins-ci.org/commit/claim-plugin/c863b59aa8fb1b8c2b679f18c14e75df4a6c1ba2
          Log:
          JENKINS-27206 - Move claim-plugin to use SimpleBuildStep

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/main/java/hudson/plugins/claim/ClaimPublisher.java http://jenkins-ci.org/commit/claim-plugin/c863b59aa8fb1b8c2b679f18c14e75df4a6c1ba2 Log: JENKINS-27206 - Move claim-plugin to use SimpleBuildStep

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pom.xml
          src/main/resources/hudson/plugins/claim/ClaimedBuildsReport/buildListTable.jelly
          src/test/java/hudson/plugins/claim/ClaimWorkflowTest.java
          http://jenkins-ci.org/commit/claim-plugin/aec467480ca9b130b07b3ca41da5ec5f986ffbb4
          Log:
          JENKINS-27206 - Fixing view, adding test.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/main/resources/hudson/plugins/claim/ClaimedBuildsReport/buildListTable.jelly src/test/java/hudson/plugins/claim/ClaimWorkflowTest.java http://jenkins-ci.org/commit/claim-plugin/aec467480ca9b130b07b3ca41da5ec5f986ffbb4 Log: JENKINS-27206 - Fixing view, adding test.

          Code changed in jenkins
          User: ki82
          Path:
          pom.xml
          src/main/java/hudson/plugins/claim/ClaimPublisher.java
          src/main/resources/hudson/plugins/claim/ClaimedBuildsReport/buildListTable.jelly
          src/test/java/hudson/plugins/claim/ClaimWorkflowTest.java
          http://jenkins-ci.org/commit/claim-plugin/7e091acf7403ce1dca97fd440ed39780a97ce841
          Log:
          Merge pull request #18 from abayer/jenkins-27206

          JENKINS-27206 - Move claim-plugin to use SimpleBuildStep

          Compare: https://github.com/jenkinsci/claim-plugin/compare/109ee7f7ab48...7e091acf7403

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: ki82 Path: pom.xml src/main/java/hudson/plugins/claim/ClaimPublisher.java src/main/resources/hudson/plugins/claim/ClaimedBuildsReport/buildListTable.jelly src/test/java/hudson/plugins/claim/ClaimWorkflowTest.java http://jenkins-ci.org/commit/claim-plugin/7e091acf7403ce1dca97fd440ed39780a97ce841 Log: Merge pull request #18 from abayer/jenkins-27206 JENKINS-27206 - Move claim-plugin to use SimpleBuildStep Compare: https://github.com/jenkinsci/claim-plugin/compare/109ee7f7ab48...7e091acf7403

          Andrew Bayer added a comment -

          Fixed in next release (tentatively 2.8).

          Andrew Bayer added a comment - Fixed in next release (tentatively 2.8).

          Hi, just tried to use it, but I get a NPE on ClaimPublisher:62, could you please provide a short example that's working for you so that I can check if I screwed up something?

          node {
              echo "hello world"
              step([$class: 'ClaimPublisher'])
          }
          

          Looking at the tests and code, I'm wondering if the issue isn't related to the fact that due to how Pipeline works, the ClaimPublisher step is gonna be called immediately and not after the build has finished. In the test, catchError is called before that step, hence force-setting a result IIUC.

          The line 62 is:

          if (build.getResult().isWorseThan(Result.SUCCESS)) {
          

          WDYT?

          Just wanted to discuss this before, but I guess I could propose a PR for that if need be.

          Cheers

          Baptiste Mathus added a comment - Hi, just tried to use it, but I get a NPE on ClaimPublisher:62, could you please provide a short example that's working for you so that I can check if I screwed up something? node { echo "hello world" step([$class: 'ClaimPublisher' ]) } Looking at the tests and code, I'm wondering if the issue isn't related to the fact that due to how Pipeline works, the ClaimPublisher step is gonna be called immediately and not after the build has finished. In the test, catchError is called before that step, hence force-setting a result IIUC. The line 62 is: if (build.getResult().isWorseThan(Result.SUCCESS)) { WDYT? Just wanted to discuss this before, but I guess I could propose a PR for that if need be. Cheers

          Andrew Bayer added a comment -

          Hmm, yeah. I guess we could change that to if (build.getResult() == null || build.getResult().isWorseThan(Result.SUCCESS)) { to get it to work when called from a Pipeline job but still behave like normal outside...but then all Pipeline builds will show up eligible to be claimed, not just failed ones. This is one of those cases where the Pipeline design doesn't fit right with Publishers...

          Andrew Bayer added a comment - Hmm, yeah. I guess we could change that to if (build.getResult() == null || build.getResult().isWorseThan(Result.SUCCESS)) { to get it to work when called from a Pipeline job but still behave like normal outside...but then all Pipeline builds will show up eligible to be claimed, not just failed ones. This is one of those cases where the Pipeline design doesn't fit right with Publishers...

          Hi, not sure to understand how to use it. I get the same NPE as batmat (ClaimPublisher:62).

          The only way I've found for now is to do something like this :

          try {
            echo "boum"  
            sh "mvn is-not-in-PATH"
          } catch (err) {
            currentBuild.result = hudson.model.Result.FAILURE
            step([$class: 'ClaimPublisher'])   
          }
          

          is there another way ?

          Michael Pailloncy added a comment - Hi, not sure to understand how to use it. I get the same NPE as batmat (ClaimPublisher:62). The only way I've found for now is to do something like this : try { echo "boum" sh "mvn is-not-in-PATH" } catch (err) { currentBuild.result = hudson.model.Result.FAILURE step([$class: 'ClaimPublisher' ]) } is there another way ?

          Hi Michael Pailloncy, You will get the same NPE if there is any exception in try block.
          You are not getting now as there is no exception thrown in your try and ClaimPublisher code was not reached.

          selvaraj muniappan added a comment - Hi Michael Pailloncy, You will get the same NPE if there is any exception in try block. You are not getting now as there is no exception thrown in your try and ClaimPublisher code was not reached.

            abayer Andrew Bayer
            nharniman Nigel Harniman
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: