Skip to content

[JENKINS-4930] Next build number plugin should allow decrementing #19180

Closed

Description

@jenkins-infra-bot

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!!!


Originally reported by jonny5, imported from: Next build number plugin should allow decrementing
  • assignee: kohsuke
  • status: Closed
  • priority: Blocker
  • component(s): core
  • resolution: Fixed
  • resolved: 2010-05-31T09:19:29+00:00
  • votes: 0
  • watchers: 0
  • imported: 2025-11-24
Raw content of original issue

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!!!

  • environment: Platform: All, OS: All
1 attachment

Activity

  1. jenkins-infra-bot commented on Dec 1, 2009

    @jenkins-infra-bot
    Author
    abayer:
    • Original comment link
    • Raw content of original comment:

      Moving to new next-build-number component.

    Moving to new next-build-number component.

  2. jenkins-infra-bot commented on Feb 9, 2010

    @jenkins-infra-bot
    Author
    hmonteiro:
    • Original comment link
    • Raw content of original comment:

      Just to let know that, although the plugin's name is "Next build number", I wasn't expceting to allow only to jump a build number forward, only.

      I installed it because I thought it would allow me to specify the next build number, not as "next" (increasing) but has the number I wanted, either increasing or decreasing. I was also expecting to even be able to specify the same number as an existing build if, and only if, the build wasn't successfull or aborted.

      That was what I was wondering this plugin did.

    Just to let know that, although the plugin's name is "Next build number", I wasn't expceting to allow only to jump a build number forward, only.

    I installed it because I thought it would allow me to specify the next build number, not as "next" (increasing) but has the number I wanted, either increasing or decreasing. I was also expecting to even be able to specify the same number as an existing build if, and only if, the build wasn't successfull or aborted.

    That was what I was wondering this plugin did.

  3. jenkins-infra-bot commented on Feb 9, 2010

    @jenkins-infra-bot
    Author
    hmonteiro:
    • Original comment link
    • Raw content of original comment:

      It would be nice that we could specify a past "next build number" only until the last successful build number, that is, allow only to replace failed or aborted past builds.

      example: Builds: #8 - Failed #7 - Aborted #6 - Failed #5 - Aborted #4 - Success #3 - Success #2 - Aborted #1 - Success

      "Next build number" should allow that the smaller number to be specified be #5, because #4 was already successful (the last successful build found). So, by specifying #5, builds #6, #7, #8 would be automatically deleted, and the next build would be #5.

      This behaviour would be of tremendous help, since there are alot of aborted or failed builds when a new job is created and fine tuned until it starts working as it is supposed to. So instead of deleting failed/aborted builds on disk, and reloading hudson's configuration this plugin could clean-up unecessary failed/aborted job's from build's history.

      Reloading hudson configurations in large hudson deployments it's basically impossible to do so, because of constant running builds that can't be stopped (some can take several hours to build).

      ULTIMATE BENEFIT of this feature: decreasing hudson's downtime, by removing the need of constantly reloading hudson's configuration in some situations.

    It would be nice that we could specify a past "next build number" only until the last successful build number, that is, allow only to replace failed or aborted past builds.

    example:
    Builds:
    #8 - Failed
    #7 - Aborted
    #6 - Failed
    #5 - Aborted
    #4 - Success
    #3 - Success
    #2 - Aborted
    #1 - Success

    "Next build number" should allow that the smaller number to be specified be #5, because #4 was already successful (the last successful build found).
    So, by specifying #5, builds #6, #7, #8 would be automatically deleted, and the next build would be #5.

    This behaviour would be of tremendous help, since there are alot of aborted or failed builds when a new job is created and fine tuned until it starts working as it is supposed to.
    So instead of deleting failed/aborted builds on disk, and reloading hudson's configuration this plugin could clean-up unecessary failed/aborted job's from build's history.

    Reloading hudson configurations in large hudson deployments it's basically impossible to do so, because of constant running builds that can't be stopped (some can take several hours to build).

    ULTIMATE BENEFIT of this feature: decreasing hudson's downtime, by removing the need of constantly reloading hudson's configuration in some situations.

  4. jenkins-infra-bot commented on Mar 11, 2010

    @jenkins-infra-bot
    Author
    jonny5:
    • Original comment link
    • Raw content of original comment:

      I had a look at the code and it looks like the next build number plugin is doing everything correctly. This looks like an issue with Hudson:

          /**
           * 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 #getNextBuildNumber()} 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 {
              if (next > nextBuildNumber) {
                  this.nextBuildNumber = next;
                  saveNextBuildNumber();
              }
          }
      

      I'm just wondering if this test for (next > nextBuildNumber) is really necessary...the test isn't done when reading from a file. It should really be checking if there are any builds between next and nextBuildNumber (as it is possible to delete builds).

    I had a look at the code and it looks like the next build number plugin is doing everything correctly. This looks like an issue with Hudson:

        /**
         * Programatically updates the next build number.
         * 
         * 

    * 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 #getNextBuildNumber()} 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 { if (next > nextBuildNumber) { this.nextBuildNumber = next; saveNextBuildNumber(); } }

    I'm just wondering if this test for (next > nextBuildNumber) is really necessary...the test isn't done when reading from a file. It should really be checking if there are any builds between next and nextBuildNumber (as it is possible to delete builds).

  5. jenkins-infra-bot commented on Mar 11, 2010

    @jenkins-infra-bot
    Author
    jonny5:
    • Original comment link
    • Raw content of original 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?

    I fully tested this version and it resolves this bug:

        /**
         * Programatically updates the next build number.
         * 
         * 

    * 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?

  6. jenkins-infra-bot commented on Mar 18, 2010

    @jenkins-infra-bot
    Author
    jonny5:
    • Original comment link
    • Raw content of original comment:

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

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

  7. jenkins-infra-bot commented on Mar 19, 2010

    @jenkins-infra-bot
    Author
    mdonohue:
    • Original comment link
    • Raw content of original 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.

    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.

  8. jenkins-infra-bot commented on Mar 19, 2010

    @jenkins-infra-bot
    Author
    jonny5:
    • Original comment link
    • Raw content of original 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.

    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.

  9. jenkins-infra-bot commented on May 31, 2010

    @jenkins-infra-bot
    Author
    scm_issue_link:
    • Original comment link
    • Raw content of original 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.

    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.

  10. removed
    bugFor changelog: Minor bug. Will be listed after features
    on Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions