0

Is it possible to execute a jenkins task from an application?

For instance, a user could click on a button in the application and start a jenkins task.

I'm using PHP and laravel framework.

xAngy
  • 27
  • 1
  • 9

1 Answers1

0

It's possible with Remote access API:

Simple example - sending "String Parameters":

curl -X POST JENKINS_URL/job/JOB_NAME/build \
--data token=TOKEN \
--data-urlencode json='{"parameter": [{"name":"id", "value":"123"}, {"name":"verbosity", "value":"high"}]}'

If you are using PHP, then you need to use some HTTP Client. I recommend GuzzleHTTP which is easy to integrate with Laravel.

Piotr Dawidiuk
  • 2,961
  • 1
  • 24
  • 33
  • Great, it works with Guzzle, thanks! The purpose of my question is I would like that the user is able to schedule himself a jenkins task by giving some parameters in the URL (day, month, year, hours, minutes). I tried to use "Build periodically with parameters" in the jenkins task: H * * * * %Parameter1=Parameter1 url: http://myuser:usertoken@localhost:8080/job/myJenkinsTask/buildWithParameters?Parameter1=myParam&token=myToken As you see, it's not the right way to do that. I would like to replace some * by the parameters sent into the url. Do you know how I can do that? – xAngy Jan 03 '17 at 10:06
  • @xAngy Ok, so you are trying to edit job's configurations. The answer is there http://stackoverflow.com/questions/22498315/how-can-i-update-a-jenkins-job-using-the-api – Piotr Dawidiuk Jan 03 '17 at 11:49
  • Thank you so much for your help! – xAngy Jan 03 '17 at 12:22