Created
February 24, 2021 17:55
-
-
Save marcelaraujo/992a5de5207b806123507a914a6981db to your computer and use it in GitHub Desktop.
Revisions
-
marcelaraujo created this gist
Feb 24, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ import java.util.regex.Pattern import java.util.regex.Matcher import jenkins.branch.BranchSource import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject Pattern p = Pattern.compile("Loading\\slibrary\\s(jenkins-(\\w+)-library(@.*)?)"); Jenkins.instance.getAllItems(WorkflowMultiBranchProject.class).each { it -> if (it.fullName.contains("Maintenance")) { return } //def source = it.getSourcesList().get(BranchSource.class).getSource() //def owner = source.repoOwner //def repository = source.repository //println "${owner}/${repository}" //println it.getAllJobs().dump() def job = it.getAllJobs().find{ job -> job.asItem().name == "master" } Run lastBuild = job?.getLastBuild(); if (lastBuild == null) { println "${it.fullName} - this job has never been run" //Job has never run return } try { def log = lastBuild.getLog() //println log.length() Matcher matcher = p.matcher(log); while(matcher.find()) { println matcher.group(1) } } catch(Exception e) { println "Error on file read action: " + e.getMessage() } } return