I want to use Matrix Build in order to run the same build once for each line in a configuration file (from SCM).
So far, I’ve tried using the GroovyAxis plugin to read the file, and also passing the axis values as parameters to the build. Neither worked, and the GroovyAxis script seems to run the script during save instead of the initialization of the buid.
Is there a way to dynamically set an axis’s values? And if not, what’s the recommended way for this sort of looping?
Cheers,
Hila
--
Danny Staple
Director, ODM Solutions Ltd
w: http://www.odmsolutions.co.uk
Blog: http://orionrobots.co.uk/blog1-Danny-Staple
Hi,
I did something similar by generating the job configuration files from a script. It's not hard, you can just copy the config.xml from the job directory and insert lines as needed. The downside is that you have to click "reload configuration from disk" after running the script.
My code (link below) is in Clojure, but the same technique works in any language.
Http://github.com/clojure/build.ci
Good luck,
Stuart Sierra
Clojure.com
From: Stuart Sierra <ma...@stuartsierra.com>
To: jenkins...@googlegroups.com
Sent: Monday, September 26, 2011 6:31 AM
Subject: Re: Using a matrix build with dynamic axis values (or looping in Jenkins)
I’ve finally managed to do just what I want, so I’ll share:
I’m using the Groovy System Script task to read the file, and then the following snippet:
def build = Thread.currentThread().executable //Get current build
new File(dir,filename).eachLine{line->
def fut = hudson.model.Hudson.instance.getItem("my_test").scheduleBuild2(
0,
new hudson.model.Cause.UpstreamCause(build),
new hudson.model.ParametersAction(new hudson.model.StringParameterValue("param1",param1_value),new hudson.model.StringParameterValue("param2",param2_value))
)
def gotten = fut.get() //This returns when fut.isDone()
println gotten.getUrl() + ': ' + gotten.result
if (gotten.result.isWorseThan(build.result) ) {
build.result = gotten.result //Set this build’s result to worst child build result
}
}
From: jenkins...@googlegroups.com [mailto:jenkins...@googlegroups.com] On Behalf Of Steve Roth
Sent: יום ב 26 ספטמבר 2011 16:29
To: jenkins...@googlegroups.com
Cc: Stuart Sierra
Subject: Re: Using a matrix build with dynamic axis values (or looping in Jenkins)
I've done something similar (though not for looping).