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

"building" builds (running builds) do not show up anymore in the list of builds of a job (json API)

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core

      If you request the json representation of a job with running builds, the running builds are not returned in the list of builds in the output.

      This is important for us because we make extensive use of the jenkins API in custom information radiators. Because of this change these are unable to display any running build (because we cannot get running builds from the jenkins API anymore).

      example: there is a running build on the jenkins CI at the moment:
      build 30 of the infra_backend-merge-all-repo job. If you request the json representation of the job:

      https://ci.jenkins-ci.org/job/infra_backend-merge-all-repo/api/json?pretty=true

      build 30 is not in the "builds" list

          [JENKINS-15583] "building" builds (running builds) do not show up anymore in the list of builds of a job (json API)

          janick reynders created issue -
          Jesse Glick made changes -
          Assignee New: Jesse Glick [ jglick ]
          Jesse Glick made changes -
          Assignee Original: Jesse Glick [ jglick ]

          Jesse Glick added a comment -

          https://ci.jenkins-ci.org/job/jenkins_lts_branch/api/json?pretty while #73 is running shows

            "lastBuild" : {
              "number" : 73,
              "url" : "http://ci.jenkins-ci.org/job/jenkins_lts_branch/73/"
            }
          

          as I would expect. Did it used to also show this build in "builds"?

          Jesse Glick added a comment - https://ci.jenkins-ci.org/job/jenkins_lts_branch/api/json?pretty while #73 is running shows "lastBuild" : { "number" : 73, "url" : "http: //ci.jenkins-ci.org/job/jenkins_lts_branch/73/" } as I would expect. Did it used to also show this build in "builds" ?

          yes indeed, it used to show up in builds.

          We also run multiple builds of the same jobs in parallel. They all used to show up in builds.

          janick reynders added a comment - yes indeed, it used to show up in builds. We also run multiple builds of the same jobs in parallel. They all used to show up in builds.

          Jesse Glick added a comment -

          Did this start in 1.485 or thereabouts? Probably a regression from lazy-loading build records.

          Jesse Glick added a comment - Did this start in 1.485 or thereabouts? Probably a regression from lazy-loading build records.
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-8754 [ JENKINS-8754 ]

          I finally got some time to look around in the source code. It is caused by the changes for 1.485.

              /**
               * Gets the read-only view of all the builds.
               * 
               * @return never null. The first entry is the latest build.
               */
              @Exported(name="allBuilds",visibility=-2)
              @WithBridgeMethods(List.class)
              public RunList<RunT> getBuilds() {
                  return RunList.fromRuns(_getRuns().values());
              }
          
              /**
               * Gets the read-only view of the recent builds.
               *
               * @since 1.485
               */
              @Exported(name="builds")
              public RunList<RunT> getNewBuilds() {
                  return getBuilds().newBuilds();
              }
          

          The getBuilds() method used to be annotated with @Exported() and the getNewBuilds() method did not exist. getBuilds().newBuilds() filters out running builds on purpose:

              /**
               * Reduce the size of the list by only leaving relatively new ones.
               * This also removes on-going builds, as RSS cannot be used to publish information
               * if it changes.
               */
              public RunList<R> newBuilds() { ... }
          

          I don't know if this should still be considered a bug, since it looks like it is intended behaviour.
          I can fix my code by asking for the (hidden) allBuilds property in the REST API.

          janick reynders added a comment - I finally got some time to look around in the source code. It is caused by the changes for 1.485. /** * Gets the read-only view of all the builds. * * @ return never null . The first entry is the latest build. */ @Exported(name= "allBuilds" ,visibility=-2) @WithBridgeMethods(List.class) public RunList<RunT> getBuilds() { return RunList.fromRuns(_getRuns().values()); } /** * Gets the read-only view of the recent builds. * * @since 1.485 */ @Exported(name= "builds" ) public RunList<RunT> getNewBuilds() { return getBuilds().newBuilds(); } The getBuilds() method used to be annotated with @Exported() and the getNewBuilds() method did not exist. getBuilds().newBuilds() filters out running builds on purpose: /** * Reduce the size of the list by only leaving relatively new ones. * This also removes on-going builds, as RSS cannot be used to publish information * if it changes. */ public RunList<R> newBuilds() { ... } I don't know if this should still be considered a bug, since it looks like it is intended behaviour. I can fix my code by asking for the (hidden) allBuilds property in the REST API.

          Jesse Glick added a comment -

          Seems to me that this is a regression: existing clients relying on builds should not have to be changed. getBuilds should once again be exported to the remote API as simply builds with default visibility, and newBuilds can be added as desired.

          Jesse Glick added a comment - Seems to me that this is a regression: existing clients relying on builds should not have to be changed. getBuilds should once again be exported to the remote API as simply builds with default visibility, and newBuilds can be added as desired.
          pedro reis made changes -
          Link New: This issue is duplicated by JENKINS-15704 [ JENKINS-15704 ]

            Unassigned Unassigned
            janickr janick reynders
            Votes:
            4 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: