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

Next build number plugin should allow decrementing

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Platform: All, OS: All
    • Similar Issues:

      Description

      Firstly, it doesn't look like there's a subcomponent defined for the "Next Build
      Number" plugin, so I've just assigned this to "plugin".

      There is a case when a user has launched a build (either manually or scheduled)
      and it needs to be deleted and the same (or similar) build run again. This
      happens when there is some kind of network or power outage unrelated to the
      source code.

      In this case, I'm still having to edit the "nextBuildNumber" files on the disk
      and reload the configuration from disk. This is quite annoying because it
      doesn't work well when builds are running, so you must have some downtime.

      To keep a long story short, it would be nice to be able to decrement the build
      number using the "Next Build Number" plugin as this plugin is awesome and has
      saved me a lot of time!!!

        Attachments

          Activity

          Hide
          jonny5 jonny5 added a comment -

          I fully tested this version and it resolves this bug:

              /**
               * Programatically updates the next build number.
               * 
               * <p>
               * Much of Hudson assumes that the build number is unique and monotonic, so
               * this method can only accept a new value that's bigger than
               * {@link #getLastBuild()} returns. Otherwise it'll be no-op.
               * 
               * @since 1.199 (before that, this method was package private.)
               */
              public synchronized void updateNextBuildNumber(int next) throws IOException {
                  RunT lastBuild = getLastBuild();
                  if (next > lastBuild.getNumber()) {
                      this.nextBuildNumber = next;
                      saveNextBuildNumber();
                  }
              }
          

          I don't have permission to submit, is someone able to do it for me?

          Show
          jonny5 jonny5 added a comment - I fully tested this version and it resolves this bug: https://svn.dev.java.net/svn/hudson/trunk/hudson/main/core/src/main/java/hudson/model/Job.java /** * Programatically updates the next build number. * * <p> * Much of Hudson assumes that the build number is unique and monotonic, so * this method can only accept a new value that's bigger than * {@link #getLastBuild()} returns. Otherwise it'll be no-op. * * @since 1.199 (before that, this method was package private .) */ public synchronized void updateNextBuildNumber( int next) throws IOException { RunT lastBuild = getLastBuild(); if (next > lastBuild.getNumber()) { this .nextBuildNumber = next; saveNextBuildNumber(); } } I don't have permission to submit, is someone able to do it for me?
          Hide
          jonny5 jonny5 added a comment -

          Here is the diff file for Job.java to make it easier for someone to apply the patch

          Show
          jonny5 jonny5 added a comment - Here is the diff file for Job.java to make it easier for someone to apply the patch
          Hide
          mdonohue mdonohue added a comment -

          I don't think this is a patch that should go in stealthily. If you want this change, I'd suggest joining the dev list, and seeing what folks think of the patch.

          The invariant that build numbers are always increasing has been there for a long time, so I suspect the consequences of removing this check would be non-trivial.

          Show
          mdonohue mdonohue added a comment - I don't think this is a patch that should go in stealthily. If you want this change, I'd suggest joining the dev list, and seeing what folks think of the patch. The invariant that build numbers are always increasing has been there for a long time, so I suspect the consequences of removing this check would be non-trivial.
          Hide
          jonny5 jonny5 added a comment -

          I don't think this deviates from the build numbers always increasing as it will only allow decrementing if builds have been deleted.

          Anyway, this can already be done by setting the number in a file and reloading the configuration from disk. This patch just helps with system downtime as you don't need to wait for all slaves to be idle to fix one job's build number.

          Show
          jonny5 jonny5 added a comment - I don't think this deviates from the build numbers always increasing as it will only allow decrementing if builds have been deleted. Anyway, this can already be done by setting the number in a file and reloading the configuration from disk. This patch just helps with system downtime as you don't need to wait for all slaves to be idle to fix one job's build number.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/main/core/src/main/java/hudson/model/Job.java
          trunk/www/changelog.html
          http://jenkins-ci.org/commit/31572
          Log:
          [FIXED JENKINS-4930] Allow the build number to be set so long as it's still bigger than the last build.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/main/core/src/main/java/hudson/model/Job.java trunk/www/changelog.html http://jenkins-ci.org/commit/31572 Log: [FIXED JENKINS-4930] Allow the build number to be set so long as it's still bigger than the last build.

            People

            Assignee:
            kohsuke Kohsuke Kawaguchi
            Reporter:
            jonny5 jonny5
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: