Skip to content

Instantly share code, notes, and snippets.

@nextrevision
Created November 23, 2016 16:19

Revisions

  1. nextrevision created this gist Nov 23, 2016.
    15 changes: 15 additions & 0 deletions jenkinsBuildWithParams.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    import jenkins.model.*

    def matchedJobs = Jenkins.instance.items.findAll { job ->
    job.name =~ /job_regex_here/
    }

    matchedJobs.each { job ->
    println job.name
    // without parameters
    //job.scheduleBuild(new Cause.UserIdCause())

    // with parameters
    //def params = [new StringParameterValue('PARAM1', 'value1')]
    //job.scheduleBuild2(0, new Cause.UserIdCause(), new ParametersAction(params))
    }