So the question is a follow up to another question asked on stackoverflow - How to upload file from command line as file parameter in jenkins
Is there a way to make the job to wait till the file upload is complete? In my case, I have some command line args in the jenkins job which takes file input as parameter. Now I am able to hit the job successfully, but before my file is uploaded, job moves ahead to execute the command line params which cause the job to fail because they need the file to be available.
So my question again - is there a way so that I can make the job to wait for upload to complete before executing cmd params? I am do this thru java and RestAssured lib.
EDIT:
RestAssured.given() .auth().basic("USERNAME", "PASSWORD") // .contentType(ContentType.URLENC) .when() .post("https://JENKINS_HOST/hudson/job/RISTSA/job/JOB_NAME/buildWithParameters" + "?file=C:/PATH_TO_FILE/SOMETHING.json&JenkinsStringParamName=test") .then() .statusCode(201);
// Already tried using file0, JenkinsFileParamName in query params
RestAssured.given().log().all() .contentType(ContentType.URLENC) .auth().basic("USERNAME", "PASSWORD") // .headers(httpHeaders("USERNAME", "PASSWORD")) .formParam("file0", "C:/PATH_TO_FILE/SOMETHING.json") .formParam("json", "{\"parameter\":[{\"name\":\"JenkinsFileParamName\",\"file\":\"file0\"},{\"name\":\JenkinsStringParamName\",\"value\":\"test\"}]}") .when() .post("https://JENKINS_HOST/hudson/job/RISTSA/job/JOB_NAME/buildWithParameters") .then() .statusCode(201);
Now I have tried the following-
- providing the content type as url encoded.
- Passing credentials as headers (My jenkins job does not need a token
- tried using "build" instead of "buildWithParameters" - does not work
- tried adding wait in jenkins job to see if it was a network upload issue
Create the second approach from official curl reference provided on jenkins docs