diff --git a/README.md b/README.md index 3cad8a8..449607a 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,18 @@ Launch a Job // bool(true) if successful or throws a RuntimeException ``` +Launch a Job with Parameters +------------ + +```php + $job = $jenkins->launchJob("clone-deploy",array( + 'name'=> , 'value'=> + 'name'=> , 'value'=> + ) + ); + var_dump($job); + // bool(true) if successful or throws a RuntimeException +``` List the jobs of a given view ----------------------------- diff --git a/src/Jenkins.php b/src/Jenkins.php index d91d4e3..dcd87ed 100755 --- a/src/Jenkins.php +++ b/src/Jenkins.php @@ -241,10 +241,15 @@ public function getExecutors($computer = '(master)') */ public function launchJob($jobName, $parameters = array()) { - if (0 === count($parameters)) { - $url = sprintf('%s/job/%s/build', $this->baseUrl, $jobName); - } else { - $url = sprintf('%s/job/%s/buildWithParameters', $this->baseUrl, $jobName); + $url = sprintf('%s/job/%s/build', $this->baseUrl, $jobName); + + if ($parameters) { + $parameters = array( + 'json' => json_encode(array( + "parameter" => $parameters + ) + ) + ); } $curl = curl_init($url); @@ -259,7 +264,6 @@ public function launchJob($jobName, $parameters = array()) } curl_setopt($curl, \CURLOPT_HTTPHEADER, $headers); - curl_exec($curl); $this->validateCurl($curl, sprintf('Error trying to launch job "%s" (%s)', $jobName, $url));