My final goal is to run mvn release:prepare on my local machine to have greater control and trigger the actual mvn release:perform on Hudson, which will do the deployment in a controlled environment and archive the build log.
To achieve this, I want to upload the generated release.properties to the Hudson instance. This should be possible using the Parameterized Trigger Plugin. The tricky part is that the proposed solution on the plugin's Wikipage using buildWithParameters seems not to work, I always got HTTP/400 or HTTP/500 responses. After some tries and an analyze of the traffic with Charles I came up with two solutions, one using token authentication, the other one basic authentication. The important part seems to be to include the parameters json and Submit as well. Note that the file parameter is numbered, i.e. it is called file0.
Token authentication
curl -i -Fname=release.properties -Ffile0=@FILE_TO_UPLOAD \ -Fjson='{"parameter": {"name": "release.properties", "file": "file0"}}' \ -FSubmit=Build \ 'http://HUDSON/hudson/job/JOBNAME/build?token=TOKEN'
The advantage of this is that no further user interaction is required, however you do not know who triggered the build.
Basic HTTP authentication
curl -i -uUSERNAME -Fname=release.properties -Ffile0=@FILE_TO_UPLOAD \ -Fjson='{"parameter": {"name": "release.properties", "file": "file0"}}' \ -FSubmit=Build 'http://HUDSON/hudson/job/JOBNAME/build'
The advantage of this is you know who triggered the build.
Here's how you can trigger a job with both a file parameter and a string parameter: curl -uUSER -Fname=integration.xml -Ffile0=@integration.xml -Fname=CI_VERSION -Fvalue=5.3 -Fjson={'parameter': [{'name': 'integration.xml', 'file': 'file0'}, {'name': 'CI_VERSION', 'value': '5.3'}]} -FSubmit=Build http://JENKINS/job/JOBNAME/build
ReplyDeleteHi Guys,
ReplyDeleteI am facing a problem when i did similar kind of job.. When i try to upload couple of files to a Job in Hudson with the above curl command it shows some exception error
Can you please help me in solving this?
Hi Guys,
ReplyDeleteI am facing a problem!!!!
I want to remotely trigger a build from the script and to download the artifacts once the build is over. Is there any way that i can be notified that build is over once i trigger the build from script, since build is taking more than 30 minutes????
Have u faced any similar situations???
Thanks and Regards,
Sudharsanam.N
can you show screenshots of exactly how your parameters are built in side of jenkins? i don't understand how the jenkins job is setupand so your post command doesn't work, thanks.
ReplyDeleteHello,
ReplyDeleteit did work for me when I tried it, you are better off placing your questions at the jenkins-user list: https://groups.google.com/forum/?hl=en&fromgroups#!forum/jenkinsci-users
Regards
Mirko