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

Promoting build with custom workspace results in NullPointerException

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Promoting a build with a custom workspace results in:

      java.lang.NullPointerException
          at hudson.plugins.promoted_builds.Promotion.getUrl(Promotion.java:61)
          at hudson.model.Run.getEnvironment(Run.java:1771)
          at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:725)
          at hudson.plugins.promoted_builds.Promotion.getEnvironment(Promotion.java:74)
          at hudson.plugins.promoted_builds.Promotion$RunnerImpl.decideWorkspace(Promotion.java:107)
          ...
      

      When a build with a custom workspace is promoted, decideWorkspace(...) attempts to build the environment, which eventually results in a call to getUrl() before the target build number has been initialized. Promotion guards against this in its own getEnvironment(TaskListener) implementation, however, it still ends up getting called by Run.getEnvironment(TaskListener).

      Several people have also reported this in the comments on the plugin wiki.

      I'll be submitting a pull request in GitHub shortly with a proposed solution.

        Attachments

          Activity

          Hide
          mrobinet mrobinet added a comment -
          Show
          mrobinet mrobinet added a comment - See pull request in GitHub: https://github.com/jenkinsci/promoted-builds-plugin/pull/4
          Hide
          petehayes Peter Hayes added a comment -

          Thanks for the solution. One thing that I've noticed Kohsuke do in the past is to support a graceful downgrade option. Could you make sure your solution accommodates that?

          Show
          petehayes Peter Hayes added a comment - Thanks for the solution. One thing that I've noticed Kohsuke do in the past is to support a graceful downgrade option. Could you make sure your solution accommodates that?
          Hide
          mrobinet mrobinet added a comment -

          Downgrading is not affected. <targetBuildNumber> is no longer serialized to jobs/<job name>/promotions/<promotion name>/builds/<build>/build.xml, but the old version handles this fine since it just overwrites the deserialized value using the build number from the PromotionTargetAction anyway:
          https://github.com/jenkinsci/promoted-builds-plugin/blob/master/src/main/java/hudson/plugins/promoted_builds/Promotion.java#L114

          Show
          mrobinet mrobinet added a comment - Downgrading is not affected. <targetBuildNumber> is no longer serialized to jobs/<job name>/promotions/<promotion name>/builds/<build>/build.xml, but the old version handles this fine since it just overwrites the deserialized value using the build number from the PromotionTargetAction anyway: https://github.com/jenkinsci/promoted-builds-plugin/blob/master/src/main/java/hudson/plugins/promoted_builds/Promotion.java#L114
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Mike Robinet
          Path:
          src/main/java/hudson/plugins/promoted_builds/Promotion.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/373b2d4045ed3ac5deed9647745a40d7c5ac6b31
          Log:
          [Fixed JENKINS-9254] Fix for NPE when promoting a build with a custom workspace.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mike Robinet Path: src/main/java/hudson/plugins/promoted_builds/Promotion.java http://jenkins-ci.org/commit/promoted-builds-plugin/373b2d4045ed3ac5deed9647745a40d7c5ac6b31 Log: [Fixed JENKINS-9254] Fix for NPE when promoting a build with a custom workspace.
          Hide
          mrobinet mrobinet added a comment -

          Thanks.

          Show
          mrobinet mrobinet added a comment - Thanks.

            People

            • Assignee:
              petehayes Peter Hayes
              Reporter:
              mrobinet mrobinet
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: