Search in sources :

Example 6 with FolderJob

use of com.offbytwo.jenkins.model.FolderJob 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);
        }
    }
}
Also used : BuildWithDetails(com.offbytwo.jenkins.model.BuildWithDetails) Build(com.offbytwo.jenkins.model.Build) FolderJob(com.offbytwo.jenkins.model.FolderJob) Job(com.offbytwo.jenkins.model.Job) JobWithDetails(com.offbytwo.jenkins.model.JobWithDetails) Map(java.util.Map) FolderJob(com.offbytwo.jenkins.model.FolderJob)

Aggregations

FolderJob (com.offbytwo.jenkins.model.FolderJob)6 Job (com.offbytwo.jenkins.model.Job)3 JobWithDetails (com.offbytwo.jenkins.model.JobWithDetails)3 Build (com.offbytwo.jenkins.model.Build)2 BuildWithDetails (com.offbytwo.jenkins.model.BuildWithDetails)1 Map (java.util.Map)1 Test (org.junit.Test)1