Put your build flow in a groovy class, and reference it in the build flow
like:

File myFile = new File("/var/lib/jenkins/groovy/myClass.groovy");
Class myUtils = new
GroovyClassLoader(getClass().getClassLoader()).parseClass(myFile);

myUtils.dsl = this

I used a bunch of static methods to define various routines; all of the
build flow methods need to be called on the dsl object you passed in:

dsl.build('job1')
dsl.build('job2')

etc.



On Mon, Apr 7, 2014 at 12:13 AM, Åsmund Østvold <asmu...@gmail.com> wrote:

> hi all,
>
> I want to thank Jenkins community for a this excellent tool.
>
> To make my work even easier I would very much like to be able to do
> regression testing on my build flow scripts. See [1] for motivation. If
> anybody have solved this already I would very much like to know the
> solution.
>
> My suggestion to solve this is to read the build flow definition from file
> and not directly from a job definition. File path should be passed in as a
> parameter. Inspired by [2] and [3] my first try was:
>
> String fileContents = new File('/tmp/flow.txt').text
> println fileContents
>
> buildClosures = []
> curClosure = { fileContents }
> buildClosures.add(curClosure)
>
> parallel(buildClosures)
>
>
> Output:
>
> Started by user anonymous <http://localhost:8080/user/null>
> build("pass")
>
> parallel {
> }
> Finished: SUCCESS
>
>
>
> I admit I did not doubted this would work but I had to try.  If anybody
> have an idea on how to do this inside a build flow definition or from a
> groovy script.
>
> I am expect an answer to this in the build flow plugin code but my
> java/groovy knowledge is limited. A pointer where the reading of the build
> job definition is done would be much appreciated.
>
>
> Regards,
> Asmund
>
> [1]
>
> Motivation:
> My 100+ jobs are with many dependencies are getting easy to mess up under
> reconfiguration, mostly checkin regression jobs. I have most of my jobs in
> freestyle configurations and the dependencies handled by the Build flow
> plugin. The freestyle jobs are mostly just executing a script, and is
> therefore easy to checkin regression on. But the build flow scripts the
> issue I now have.
>
> [2] https://groups.google.com/forum/#!topic/jenkinsci-users/dkwOzMVeYxg
> [3]
> http://stackoverflow.com/questions/7729302/how-to-read-a-file-in-groovy-into-a-string
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Marc MacIntyre

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to