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

add blocking call to get build id (CLI or build url)

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • cli
    • None

      In a multiple user context, with concurrent builds enabled, it can be difficult to find the build number. nextBuildNumber isn't always what the build number is going to be (race because of concurrent builds).

      It would be nice to have:

      http://jenkins.example.com/job/example/build?getBuildNumber that would wait until the build starts running to return the build number.

      and

      CLI counterpart; that returns when the build number is available.

          [JENKINS-9677] add blocking call to get build id (CLI or build url)

          Damien Nozay added a comment - - edited
          • hitting url for http://example.com/job/example/build?delay=0sec
          • this goes and triggers AbstractProject doBuild()
          • doBuild() does a rsp.forwardToPreviousPage(req); so we cannot know what build we triggered or what item it corresponds to in the queue
          • it does call schedule() on the Queue
          • shedule() on the Queue gives a WaitingItem
          • from the WaitingItem we can get a Future or an ID?
          • we don't need for the Future isDone() to be true or to do a get(), since we may not want to block in a HTTP call but all other info from the WaitingItem can be useful

          e.g.

          if (getHandle(req)) {
             waitingitem = Hudson.getInstance().getQueue().schedule(this, getDelay(req), getBuildCause(req));
             // do something good with waitingitem
          } else {
             rsp.forwardToPreviousPage(req);
          }
          

          Damien Nozay added a comment - - edited hitting url for http://example.com/job/example/build?delay=0sec this goes and triggers AbstractProject doBuild() doBuild() does a rsp.forwardToPreviousPage(req); so we cannot know what build we triggered or what item it corresponds to in the queue it does call schedule() on the Queue shedule() on the Queue gives a WaitingItem from the WaitingItem we can get a Future or an ID? we don't need for the Future isDone() to be true or to do a get(), since we may not want to block in a HTTP call but all other info from the WaitingItem can be useful e.g. if (getHandle(req)) { waitingitem = Hudson.getInstance().getQueue().schedule( this , getDelay(req), getBuildCause(req)); // do something good with waitingitem } else { rsp.forwardToPreviousPage(req); }

          In HTTP, long blocking call tends to be cut off by intermediaries, so it'll likely not work reliably.

          CLI currently has a command to wait until the completion of a job. I guess you'd like another switch that waits only up to the start of the execution?

          Kohsuke Kawaguchi added a comment - In HTTP, long blocking call tends to be cut off by intermediaries, so it'll likely not work reliably. CLI currently has a command to wait until the completion of a job. I guess you'd like another switch that waits only up to the start of the execution?

          Oleg Nenashev added a comment -

          "build -w" provides such feature in newest versions

          Oleg Nenashev added a comment - "build -w" provides such feature in newest versions

            Unassigned Unassigned
            dnozay Damien Nozay
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: