How to submit Jenkins job via REST API?

后端 未结 1 1932
难免孤独
难免孤独 2021-01-07 08:48

The following \'Execute system Groovy script\' Build Task updates the build\'s description to add a button that will submit another Jenkins job which is parameterized:

相关标签:
1条回答
  • 2021-01-07 09:13

    You need to use JSON. See Submitting Jobs.

    The following worked for me:

    <button 
      type='button'
      onclick='javascript:
        var another_job = function() {
          new Ajax.Request("http://localhost:8081/job/JReport2/build", {
            method: "post",
            parameters: {json: Object.toJSON({parameter: [{name: "foo", value: "fobar"}]})}
        });
      };
      another_job()'>
      Start Job
    </button>
    

    What's a bit strange that is works when the button that appears next to the build in the build list is pushed, but does not work with the button that appears on the build description itself.

    0 讨论(0)
提交回复
热议问题