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

Enable claim support from workflow

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      It should be possible to claim failed workflow builds.

        Attachments

          Activity

          Hide
          scm_issue_link 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

          Show
          scm_issue_link 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
          Hide
          scm_issue_link 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.

          Show
          scm_issue_link 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.
          Hide
          scm_issue_link 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

          Show
          scm_issue_link 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
          Hide
          abayer Andrew Bayer added a comment -

          Fixed in next release (tentatively 2.8).

          Show
          abayer Andrew Bayer added a comment - Fixed in next release (tentatively 2.8).
          Hide
          batmat 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

          Show
          batmat 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
          Hide
          abayer 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...

          Show
          abayer 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...
          Hide
          mpapo Michael Pailloncy added a comment -

          Hi, not sure to understand how to use it. I get the same NPE as Baptiste Mathus (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 ?

          Show
          mpapo Michael Pailloncy added a comment - Hi, not sure to understand how to use it. I get the same NPE as Baptiste Mathus (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 ?
          Hide
          selvarajmit 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.

          Show
          selvarajmit 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.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: