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

buildWithParameters: return a JSON string when client request it through content-type header

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Jenkins 1.460 on Debian Squeeze
    • Similar Issues:

      Description

      Right now, every call on the buildWithParameters URL will always redirect to the job page on success. If this API is queried through an Ajax call, it should return a JSON output of the current job instead. This can easily be detected based on the Content-Type http header sent by the client.

      This is useful for example if one wants to trigger a parametrized build from jQuery, and parse the result. Right now, jQuery will always get back the HTML page of the job, which makes it hard to do any error handling.

        Attachments

          Issue Links

            Activity

            Hide
            danielbeck Daniel Beck added a comment -

            You need to add /api/xml to the queue item URL. That it 404's is probably an oversight as it's never supposed to be accessed interactively?

            Still, this can probably be considered Fixed or Won't Fix, depending on how you look at it.

            Show
            danielbeck Daniel Beck added a comment - You need to add /api/xml to the queue item URL. That it 404's is probably an oversight as it's never supposed to be accessed interactively? Still, this can probably be considered Fixed or Won't Fix, depending on how you look at it.
            Hide
            andrewk Andrew Kujtan added a comment -

            I'm a little confused as to how this is supposed to work, it now returns,

            http://jenkins/queue/item/####/

            By the time I get the URL it always 404s.
            How is one supposed to "track how it passes through the queue and eventually gets built/cancelled" from the provided URL?

            Also, the 200 -> 201 change should be documented in the change logs.

            Show
            andrewk Andrew Kujtan added a comment - I'm a little confused as to how this is supposed to work, it now returns, http://jenkins/queue/item/####/ By the time I get the URL it always 404s. How is one supposed to "track how it passes through the queue and eventually gets built/cancelled" from the provided URL? Also, the 200 -> 201 change should be documented in the change logs.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Daniel Beck
            Path:
            changelog.html
            http://jenkins-ci.org/commit/jenkins/14b6e10243522cd7d3db58d55a2363ef51fe3440
            Log:
            Noted #648, #737, #733, JENKINS-13546

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: changelog.html http://jenkins-ci.org/commit/jenkins/14b6e10243522cd7d3db58d55a2363ef51fe3440 Log: Noted #648, #737, #733, JENKINS-13546
            Hide
            dogfood dogfood added a comment -

            Integrated in jenkins_main_trunk #3328
            [FIXED JENKINS-13546] (Revision 680dd4a21a575cebe37648b215b8f714848f6a15)

            Result = SUCCESS
            kohsuke : 680dd4a21a575cebe37648b215b8f714848f6a15
            Files :

            • core/src/main/java/hudson/model/ParametersDefinitionProperty.java
            Show
            dogfood dogfood added a comment - Integrated in jenkins_main_trunk #3328 [FIXED JENKINS-13546] (Revision 680dd4a21a575cebe37648b215b8f714848f6a15) Result = SUCCESS kohsuke : 680dd4a21a575cebe37648b215b8f714848f6a15 Files : core/src/main/java/hudson/model/ParametersDefinitionProperty.java
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            core/src/main/java/hudson/model/ParametersDefinitionProperty.java
            http://jenkins-ci.org/commit/jenkins/680dd4a21a575cebe37648b215b8f714848f6a15
            Log:
            [FIXED JENKINS-13546]

            Bringing this to the parity with ParameterizedJobMixIn.doBuild()

            Instead of returning JSON, it returns "201 Created" and responds with the location of the queue item, through which the caller can track how it passes through the queue and eventually gets built/cancelled.

            The approach in pull request #750 that relies on
            AbstractProject.getQueueItem() is inherently unreliable, because
            item can be immediately built before the JSON is rendered, or it might
            corresponds to other queued items if the build supports concurrent
            builds, etc.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: core/src/main/java/hudson/model/ParametersDefinitionProperty.java http://jenkins-ci.org/commit/jenkins/680dd4a21a575cebe37648b215b8f714848f6a15 Log: [FIXED JENKINS-13546] Bringing this to the parity with ParameterizedJobMixIn.doBuild() Instead of returning JSON, it returns "201 Created" and responds with the location of the queue item, through which the caller can track how it passes through the queue and eventually gets built/cancelled. The approach in pull request #750 that relies on AbstractProject.getQueueItem() is inherently unreliable, because item can be immediately built before the JSON is rendered, or it might corresponds to other queued items if the build supports concurrent builds, etc.

              People

              Assignee:
              corfr Bertrand Roussel
              Reporter:
              rborer Reynald Borer
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: