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

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

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None
    • Jenkins 1.460 on Debian Squeeze

      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.

          [JENKINS-13546] buildWithParameters: return a JSON string when client request it through content-type header

          Reynald Borer created issue -

          Code changed in jenkins
          User: Reynald Borer
          Path:
          changelog.html
          core/src/main/java/hudson/model/ParametersDefinitionProperty.java
          http://jenkins-ci.org/commit/jenkins/1409fdff1955581b91904d73781054a63f1d6f85
          Log:
          [FIXED JENKINS-13546]: return a JSON string when client request it through content-type header

          When a client uses the buildWithParameters API and request a json output, return the job definition as a json string instead of doing a redirect on the job page.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Reynald Borer Path: changelog.html core/src/main/java/hudson/model/ParametersDefinitionProperty.java http://jenkins-ci.org/commit/jenkins/1409fdff1955581b91904d73781054a63f1d6f85 Log: [FIXED JENKINS-13546] : return a JSON string when client request it through content-type header When a client uses the buildWithParameters API and request a json output, return the job definition as a json string instead of doing a redirect on the job page.
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          dogfood added a comment -

          Integrated in jenkins_main_trunk #1689
          [FIXED JENKINS-13546]: return a JSON string when client request it through content-type header (Revision 1409fdff1955581b91904d73781054a63f1d6f85)

          Result = UNSTABLE
          Kohsuke Kawaguchi : 1409fdff1955581b91904d73781054a63f1d6f85
          Files :

          • core/src/main/java/hudson/model/ParametersDefinitionProperty.java
          • changelog.html

          dogfood added a comment - Integrated in jenkins_main_trunk #1689 [FIXED JENKINS-13546] : return a JSON string when client request it through content-type header (Revision 1409fdff1955581b91904d73781054a63f1d6f85) Result = UNSTABLE Kohsuke Kawaguchi : 1409fdff1955581b91904d73781054a63f1d6f85 Files : core/src/main/java/hudson/model/ParametersDefinitionProperty.java changelog.html

          dogfood added a comment -

          Integrated in jenkins_ui-changes_branch #26
          [FIXED JENKINS-13546]: return a JSON string when client request it through content-type header (Revision 1409fdff1955581b91904d73781054a63f1d6f85)

          Result = SUCCESS
          Kohsuke Kawaguchi : 1409fdff1955581b91904d73781054a63f1d6f85
          Files :

          • core/src/main/java/hudson/model/ParametersDefinitionProperty.java
          • changelog.html

          dogfood added a comment - Integrated in jenkins_ui-changes_branch #26 [FIXED JENKINS-13546] : return a JSON string when client request it through content-type header (Revision 1409fdff1955581b91904d73781054a63f1d6f85) Result = SUCCESS Kohsuke Kawaguchi : 1409fdff1955581b91904d73781054a63f1d6f85 Files : core/src/main/java/hudson/model/ParametersDefinitionProperty.java changelog.html

          Sune Keller added a comment -

          I'm having trouble with the JSON results when scheduling several concurrent builds from a Groovy Postbuild script in another job.

          The returned JSON content does not indicate anything about the scheduled build, the queueItem object is sometimes null, and the nextBuildNumber is not reliable when scheduling multiple builds at the same time.

          The JSON returned would be infinitely more useful if it contained information about the scheduled build.

          Sune Keller added a comment - I'm having trouble with the JSON results when scheduling several concurrent builds from a Groovy Postbuild script in another job. The returned JSON content does not indicate anything about the scheduled build, the queueItem object is sometimes null, and the nextBuildNumber is not reliable when scheduling multiple builds at the same time. The JSON returned would be infinitely more useful if it contained information about the scheduled build.
          Sune Keller made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]
          Bertrand Roussel made changes -
          Status Original: Reopened [ 4 ] New: In Progress [ 3 ]
          Bertrand Roussel made changes -
          Assignee New: Bertrand Roussel [ corfr ]

          @Sune: It seems the "queueItem" should contain informations about the scheduled item, could you please provide more details about when this is null ? Is that random (for a same type of build, even if the build has been scheduled, sometimes the queueItem is null, sometimes it isn't), or is that more for some type of builds, etc ...

          Bertrand Roussel added a comment - @Sune: It seems the "queueItem" should contain informations about the scheduled item, could you please provide more details about when this is null ? Is that random (for a same type of build, even if the build has been scheduled, sometimes the queueItem is null, sometimes it isn't), or is that more for some type of builds, etc ...

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

              Created:
              Updated:
              Resolved: