Skip to content

Instantly share code, notes, and snippets.

@ollieread
Created July 4, 2014 20:44
Show Gist options
  • Save ollieread/71573e7065d4d11d2163 to your computer and use it in GitHub Desktop.
Save ollieread/71573e7065d4d11d2163 to your computer and use it in GitHub Desktop.
<?php
$baseurl = 'http://myjenkinsurl/job/jobname';
$buildJsonDirty = @file_get_contents($baseurl . '/api/json');
if($buildJsonDirty) {
$buildJsonClean = json_decode($buildJsonDirty, true);
$builds = $buildJsonClean['builds'];
foreach($builds as $build) {
$artiJsonDirty = @file_get_contents($baseurl . '/' . $build['number'] . '/api/json');
if($artiJsonDirty) {
$artiJsonClean = json_decode($artiJsonDirty, true);
$artifacts = $artiJsonClean['artifacts'];
if(!empty($artifacts) && $artiJsonClean['result'] == 'SUCCESS') {
echo '<p><strong>Build ' . $build['number'] .'</strong></p>';
foreach($artifacts as $artifact) {
echo '<p><a href="' . $baseurl . '/' . $build['number'] . '/artifact/' . $artifact['relativePath'] . '">Download ' . $artifact['displayPath'] . '</a>';
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment