I am trying to create a new job by triggering the jenkins' createItem endpoint, using the following code:
$(document).ready(function() {
$("#create").click(function (e) {
e.preventDefault();
var newJobName = $("#jobname").val();
//console.log(newJobName);
jQuery.ajax({
type: "POST",
url: "http://robot:<api1>@host/jenkins/createItem?name="+newJobName,
dataType:"xml",
contentType: "application/xml",
success:function(response){
console.log("success");
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
});
});
But i am getting 500 server error. I know I should post the
file also but i don't really know how to extend this code to be able to post the file also.
I am using a self-written client to interact with jenkins and the API is works well for build triggering.
Any help would be really appreciated!