[JIRA] (JENKINS-58787) Be able to create a job posting config.xml - Or improve docs

6 views
Skip to first unread message

cardenas.mcb@gmail.com (JIRA)

unread,
Aug 2, 2019, 10:42:03 AM8/2/19
to jenkinsc...@googlegroups.com
Manuel Cardenas created an issue
 
Jenkins / Improvement JENKINS-58787
Be able to create a job posting config.xml - Or improve docs
Issue Type: Improvement Improvement
Assignee: Janario Oliveira
Components: http-request-plugin
Created: 2019-08-02 14:41
Priority: Minor Minor
Reporter: Manuel Cardenas

I want to be able to create jobs just by posting config.xml to the jenkins instance using the httprequest step

 

 

def response = httpRequest authentication: 'JENKINS', customHeaders: [[maskValue: false, name: 'Content-type', value: 'application/xml']], 
ignoreSslErrors: true, outputFile: 'config.xml', responseHandle: "STRING", url: 'http://localhost:8080/job/FOLDER/job/template/config.xml', 
validResponseCodes: '100:399' 
def myxml= "'"+response.content+"'"
def response1 = httpRequest authentication: 'JENKINS', customHeaders: [[maskValue: false, name: 'Content-Type', value: 'TEXT_PLAIN'],
[maskValue: false, name: 'requestBody', value: myxml],
[maskValue: false, name: 'consoleLogResponseBody', value: 'true'],
[maskValue: false, name: 'authentication', value: 'BASIC']
], httpMode: 'POST', ignoreSslErrors: true, url: "http://localhost:8080/createItem?name=new_job" 

Or

def response = httpRequest authentication: 'JENKINS', customHeaders: [[maskValue: false, name: 'Content-type', value: 'application/xml']], 
ignoreSslErrors: true, outputFile: 'config.xml', responseHandle: "STRING", url: 'http://localhost:8080/job/FOLDER/job/template/config.xml', 
validResponseCodes: '100:399' 
def myxml= "'"+response.content+"'"
def response1 = httpRequest authentication: 'JENKINS', customHeaders: [[maskValue: false, name: 'Content-Type', value: 'multipart/form-data'],
], httpMode: 'POST',multipartName: 'config.xml', ignoreSslErrors: true, url: "http://localhost:8080/createItem?name=new_job"   

 

But this renders a 400 error

hudson.AbortException: Fail: the returned code 400 is not in the accepted range: [[100‥399]]
	at jenkins.plugins.http_request.HttpRequestExecution.responseCodeIsValid(HttpRequestExecution.java:353)
	at jenkins.plugins.http_request.HttpRequestExecution.processResponse(HttpRequestExecution.java:363)
	at jenkins.plugins.http_request.HttpRequestExecution.authAndRequest(HttpRequestExecution.java:279)
	at jenkins.plugins.http_request.HttpRequestExecution.call(HttpRequestExecution.java:215)
Caused: java.lang.IllegalStateException
	at jenkins.plugins.http_request.HttpRequestExecution.call(HttpRequestExecution.java:218)

 

It would be good to have an improvement allowing this to work or improve the documentation on this regard.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

janario.oliveira@gmail.com (JIRA)

unread,
Sep 8, 2019, 9:38:02 AM9/8/19
to jenkinsc...@googlegroups.com
Janario Oliveira closed an issue as Not A Defect
Change By: Janario Oliveira
Status: Open Closed
Resolution: Not A Defect

janario.oliveira@gmail.com (JIRA)

unread,
Sep 8, 2019, 9:38:02 AM9/8/19
to jenkinsc...@googlegroups.com
Janario Oliveira commented on Improvement JENKINS-58787
 
Re: Be able to create a job posting config.xml - Or improve docs

This is more related to Jenkins authorization itself not http request plugin

But to manage Jenkins jobs I would recommend JobDsl plugin which is made for this https://jenkinsci.github.io/job-dsl-plugin/

Otherwise you'll have to manage the Jenkins authorization to allow those requests, which I'm not sure on how to help (You could try on the Jenkins mail list)

Reply all
Reply to author
Forward
0 new messages