0

I am able to convert curl POST jenkins job call into php cURL. Here is my solution:

PHP cURL POST Jenkins job with parameters

which has something like:

$url = "http://build:f9280f75396f83a0@mobile-jenkins.domain.com:8080/job/android-test/buildWithParameters";     
$data = "POST_RESULTS=true&RUN_ID=".$testrun_id."&CHECK_NAME=SampleAutomatedPlan";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

Now I want to incorporate description field for the jenkins job so I can set it in beginning.

Here is what I am referring to: How can I set Jenkins build description while triggering build via curl? which shows setting up of description via command line:

curl -v -X POST --data-urlencode "MyDescription=This is my desc" "http://[myServer]/job/[jobName]/buildWithParameters" 

How to add such description parameter into above php curl method/call?

Community
  • 1
  • 1
Pratik Jaiswal
  • 309
  • 7
  • 26

1 Answers1

1

If you don't like using post parameters, how about appending them onto the url?

$url = "http://build:f9280f75396f83a0@mobile-jenkins.domain.com:8080/job/android-test/buildWithParameters?POST_RESULTS=true&RUN_ID=".$testrun_id."&CHECK_NAME=SampleAutomatedPlan&MyDescription=This+is+my+desc"
Daniel Omoto
  • 2,431
  • 17
  • 15