Skip to content

Commit

Permalink
Add getQueueItem method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexj12 committed Oct 17, 2019
1 parent 7e61877 commit 8cfe2f4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Jenkins.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,28 @@ public function getQueue()
return new Jenkins\Queue($infos, $this);
}

/**
* @return Jenkins\Queue
* @throws \RuntimeException
*/
public function getQueueItem($id)
{
$url = sprintf('%s/queue/item/%s/api/json', $this->baseUrl, $id);
$curl = curl_init($url);

curl_setopt($curl, \CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($curl);

$this->validateCurl($curl, sprintf('Error during getting information for queue on %s, queue item: %s', $this->baseUrl, $id));

$infos = json_decode($ret);
if (!$infos instanceof \stdClass) {
throw new \RuntimeException('Error during json_decode');
}

return $infos;
}

/**
* @return Jenkins\View[]
*/
Expand Down

0 comments on commit 8cfe2f4

Please sign in to comment.