This might have been answered already, but I don’t even know what to look for so I’m posting openly.
I have a seeder job that is a seeder.Jenkinsfile that has some logic to create jobs using a class I created jobs.groovy.
Everything works well with this model. I use a List to abstract complexity out of the job’s creation process and I end up iterating over that list/map and I use the Job(jobName) and other parameters that I pass to setup cron, enable/disable, params, etc...
works beautifully.
Problem is I have to replicate that logic in every seeder job to iterate over the data structure (List/Map) I created (I have plenty of seeder jobs). So if I update the logic o add a new parameter, I need to update the logic in every seeder.
I could move that logic into the class Jobs.groovy and that would be ideal because I only need to modify the logic in the class and I can call the Job() from that groovy file.
The problem I face when doing this is that the Jobs.groovy file doesn’t have access to the Job() method, or any JobDSL method for that matter.
I tried importing the javaposse.jobdsl.dsl.Job method into my Jobs.groovy but this didn’t work.
I end up with a "No signature of method:
com.team.Jobs$_allJobs_closure1.job() error.
Any help is appreciated.
Thank you