use of com.offbytwo.jenkins.model.Build in project blueocean-plugin by jenkinsci.
the class ClassicJobApi method abortAllBuilds.
public void abortAllBuilds(Folder folder, String pipeline) throws IOException {
JobWithDetails job = jenkins.getJob(getFolder(folder, false), pipeline);
for (Build build : job.getBuilds()) {
if (build.details().getResult() == null) {
build.details().Stop();
logger.info("Stopped build " + folder.getPath(pipeline) + " - #" + build.getNumber());
}
}
Optional<FolderJob> folderJobOptional = jenkins.getFolderJob(job);
if (folderJobOptional.isPresent()) {
for (String s : folderJobOptional.get().getJobs().keySet()) {
abortAllBuilds(folder.append(pipeline), s);
}
}
}
use of com.offbytwo.jenkins.model.Build in project fabric8 by fabric8io.
the class JenkinsAsserts method displayJobs.
public static void displayJobs(JenkinsServer jenkins, Map<String, Job> jobs, String indent) throws IOException {
Set<Map.Entry<String, Job>> entries = jobs.entrySet();
for (Map.Entry<String, Job> entry : entries) {
String jobName = entry.getKey();
Job job = entry.getValue();
String suffix = "";
JobWithDetails details = job.details();
if (details != null) {
Build lastBuild = details.getLastBuild();
if (lastBuild != null) {
BuildWithDetails buildDetails = lastBuild.details();
if (buildDetails != null) {
String buildId = buildDetails.getId();
if (buildId != null) {
suffix = ": #" + buildId;
}
}
}
}
System.out.println(indent + jobName + suffix);
Optional<FolderJob> optional = jenkins.getFolderJob(job);
if (optional.isPresent()) {
FolderJob folderJob = optional.get();
Map<String, Job> children = folderJob.getJobs();
displayJobs(jenkins, children, indent + INDENT);
}
}
}
use of com.offbytwo.jenkins.model.Build in project fabric8 by fabric8io.
the class JenkinsAsserts method assertJobHasBuild.
public static Build assertJobHasBuild(JenkinsServer jenkins, String jobName) {
JobWithDetails job = assertJobExists(jenkins, jobName);
Build lastBuild = job.getLastBuild();
assertNotNull("No lastBuild for job `" + jobName + "`", lastBuild);
return lastBuild;
}
Aggregations