'Jenkins Job-dsl minimize repeated code? pipelineJob
I'm new to jenkins/job-dsl but, I have made managed to create some scripts that make multiple jobs in multiple locations.
it works fine however, these scripts have ALOT of repeated code..
These scripts are a little like this.. create_job.groovy
def pipeline = \[
'job-name': \[
'parm1': 'blar',
'parm2': 'blar
\],
'job-name-2': \[
'parm1': 'blar',
'parm2': 'blar
\]
\]
pipeline.each{job_name, job_parm -\>
pipelineJob('${job_name}') {
..you get the point..
}
}
I have 10 scripts all with near identical pipeline.each code, the only thing that really changes are the params, job names and job locations.
I have looked at seed dls jobs (google suggestion) and tried to make a very basic DSLFactory / package utilities but had no luck..
what im hoping for (if possible) is to create a class PipelineBuilder which contains a method that will create the pipelineJob, then I would have the logic in a single location and i could feed the variable data accross.
But, I'm having issues passing data from one groovy file to another..(even after importing the class)
I've been google-ing for a few days - but if anyone could maybe point to a working example that would be great.
thanks,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
