Jenkins Bulk or Multi trigger for release maven plugin

一个人想着一个人 提交于 2019-12-11 06:07:16

问题


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


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/14406897/jenkins-bulk-or-multi-trigger-for-release-maven-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!