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)

          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.

          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 added a comment -

          This problem also occurs at python api.
          I think we can use "lastBuild" element instead of "builds".

          pedro reis added a comment - This problem also occurs at python api. I think we can use "lastBuild" element instead of "builds".

          @pedro "lastBuild" just returns the last build. If you run multiple builds of the same job concurrently, then "allBuilds" is the only property that contains all the running builds (in addition to the builds from "builds").

          janick reynders added a comment - @pedro "lastBuild" just returns the last build. If you run multiple builds of the same job concurrently, then "allBuilds" is the only property that contains all the running builds (in addition to the builds from "builds").

          pedro reis added a comment -

          @janick In python I don't see any "allBuilds".

          There is only: builds, firstBuild, lastBuild, lastCompletedBuild, lastFailedBuild, lastStableBuild, lastSuccessfulBuild, lastUnstableBuild, lastUnsuccessfulBuild,

          pedro reis added a comment - @janick In python I don't see any "allBuilds". There is only: builds, firstBuild, lastBuild, lastCompletedBuild, lastFailedBuild, lastStableBuild, lastSuccessfulBuild, lastUnstableBuild, lastUnsuccessfulBuild,

          yes it's a hidden property: it will be returned if you ask for it explicitly (using the "tree" query parameter: see "Controlling the amount of data you fetch")

          janick reynders added a comment - yes it's a hidden property: it will be returned if you ask for it explicitly (using the "tree" query parameter: see "Controlling the amount of data you fetch")

          Jesse Glick added a comment -

          This is still an apparent regression and needs to be fixed, not worked around in clients.

          Jesse Glick added a comment - This is still an apparent regression and needs to be fixed, not worked around in clients.

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          changelog.html
          core/src/main/java/hudson/model/Job.java
          core/src/main/java/hudson/util/RunList.java
          http://jenkins-ci.org/commit/jenkins/fe9f676028773df181f0b9ec823b3cdd08d5cf3d
          Log:
          [FIXED JENKINS-15583]

          Report 100 recent builds in the JSON API, including in-progress builds.

          Not reporting all the builds since this would nullify the lazy loading
          effect. Will introduce a pagenation API that supports retrieval.


          You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com.
          For more options, visit https://groups.google.com/groups/opt_out.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html core/src/main/java/hudson/model/Job.java core/src/main/java/hudson/util/RunList.java http://jenkins-ci.org/commit/jenkins/fe9f676028773df181f0b9ec823b3cdd08d5cf3d Log: [FIXED JENKINS-15583] Report 100 recent builds in the JSON API, including in-progress builds. Not reporting all the builds since this would nullify the lazy loading effect. Will introduce a pagenation API that supports retrieval. – You received this message because you are subscribed to the Google Groups "Jenkins Commits" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out .

          dogfood added a comment -

          Integrated in jenkins_main_trunk #2368
          [FIXED JENKINS-15583] (Revision fe9f676028773df181f0b9ec823b3cdd08d5cf3d)

          Result = UNSTABLE
          kohsuke : fe9f676028773df181f0b9ec823b3cdd08d5cf3d
          Files :

          • core/src/main/java/hudson/util/RunList.java
          • changelog.html
          • core/src/main/java/hudson/model/Job.java

          dogfood added a comment - Integrated in jenkins_main_trunk #2368 [FIXED JENKINS-15583] (Revision fe9f676028773df181f0b9ec823b3cdd08d5cf3d) Result = UNSTABLE kohsuke : fe9f676028773df181f0b9ec823b3cdd08d5cf3d Files : core/src/main/java/hudson/util/RunList.java changelog.html core/src/main/java/hudson/model/Job.java

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

              Created:
              Updated:
              Resolved: