User123456
User123456

Reputation: 691

Jenkins Bulk or Multi trigger for release maven plugin

I have a need to bulk trigger maven release plugin in jenkins for multiple projects. They are not dependent of each other and some of them have modules.

In jenkins you can release each of them one by one, but I'm looking for a method to trigger all at once and potentially label all with same release number.

E.g.

Project A 
Project B 
... 
Project N

Maven Release (some select query) 
Next Snapshot version (1.1.0-SNAPSHOT)
Next release version (1.0.0)

and then project A..N would be released with that single build trigger .. anything like that available?

I know about multi- and bulk plugin but they dont seem to build maven release.

/Thanks

Upvotes: 1

Views: 2110

Answers (2)

simbo1905
simbo1905

Reputation: 6822

As per this answer you can build a list of jobs and parameters and then run the jobs in parallel:

stage('testing') {
  def jobs = [:]

  [1,2,3,4,5].each{
    i -> jobs["Test${i}"] = {
        build job: 'Test', 
        parameters: [string(name: 'theparam', value: "${i}")],
        quietPeriod: 2
    }
  }
  parallel jobs
}

There it is using numbers for the names but you can use arbitrary names.

You can get more sophisticated and download the list of jobs to release into a file and run the jobs named in the file:

stage ('download release spec') {
    dir('${WORKSPACE}') {
        sh 'curl -LO https://my.server.com/path/$MASTER_RELEASE/jobs.txt'
    }
}
stage('run jobs in spec') {
    dir('${WORKSPACE}') {
        // read our one line of jobs to run and split it into an array of jobs to run
        def fileData = readFile('jobs.txt')
        def names = fileData.tokenize( ',' )

        // short hand for creating an empty map
        def jobs = [:]

        // https://stackoverflow.com/a/51306175/329496
        names.each{
            i -> jobs["${i}"] = {
                println "parallel build job: $i"
                build job: "${i}"
            }
        }
        parallel jobs
    }
} 

The first code snippet shows how to pass parameters to the builds. Groovy has some hidden functions for merging lists such as transpose that could make it easy to merge a "jobs.txt" and "params.txt" into a list that you can run .each over to extract the job name and its parameters. You can put some sed, awk or python into the first stage to compute all the files from a structured release document. That way your build can be downloading a nicely formatted release document and munge that into a bunch of jobs and release parameters to run.

Upvotes: 4

dharma
dharma

Reputation: 21

i was looking at the following one .. seems to help.. https://dev.c-ware.de/confluence/display/PUBLIC/Developing+a+Jenkins+Plugin+for+the+Maven+Release+Plugin

Upvotes: 2

Related Questions