Skip to content

Instantly share code, notes, and snippets.

@AdamSaleh
Created February 26, 2018 13:45
Show Gist options
  • Select an option

  • Save AdamSaleh/a8b9a029a17bfad98b210a8d7c94cb50 to your computer and use it in GitHub Desktop.

Select an option

Save AdamSaleh/a8b9a029a17bfad98b210a8d7c94cb50 to your computer and use it in GitHub Desktop.
//https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/buildJobsMatchingPattern.groovy
import jenkins.model.*
import hudson.model.*
def jobPattern = args[0]
// Pattern to search for. Regular expression.
//def jobPattern = "test_.*"
def matchedJobs = Jenkins.instance.items.findAll { job ->
job.name =~ /$jobPattern/
}
matchedJobs.each { job ->
println "Scheduling matching job ${job.name}"
job.scheduleBuild(new Cause.UserIdCause())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment