-
Bug
-
Resolution: Unresolved
-
Major
-
None
The example for the jobDsl pipeline step shows usage that cannot actually be used:
https://github.com/jenkinsci/job-dsl-plugin/wiki/User-Power-Moves#use-job-dsl-in-pipeline-scripts
node { jobDsl scriptText: 'job("example-2")' jobDsl targets: ['jobs/projectA/*.groovy', 'jobs/common.groovy'].join('\n'), removedJobAction: 'DELETE', removedViewAction: 'DELETE', lookupStrategy: 'SEED_JOB', additionalClasspath: ['libA.jar', 'libB.jar'].join('\n') }
This will always delete the job "example-2" because the second step DELETEs all unfreferenced items, unless of course one of the scripts also happens to create a job named "example-2".
From my brief look at the source, I don't think this would be easy to implement. However, it would still be incredibly useful to be able to call jobDsl multiple times with different arguments.
- is caused by
-
JENKINS-29784 DSL Job View shows many copies of Generated Items
-
- Closed
-
- is duplicated by
-
JENKINS-50875 multiple jobDSL() pipeline steps destroys all but the last
-
- Closed
-
- relates to
-
JENKINS-59158 Support running Job DSL scripts in parallel in pipeline with DISABLE or DELETE action
-
- Open
-
[JENKINS-44142] Step jobDsl can be used at most once in pipeline with DELETE
Link |
New:
This issue is duplicated by |
Link |
New:
This issue is caused by |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Open [ 1 ] | New: Fixed but Unreleased [ 10203 ] |
Resolution | Original: Fixed [ 1 ] | |
Status | Original: Fixed but Unreleased [ 10203 ] | New: Reopened [ 4 ] |
I've taken another look at this.
When multiple job-dsl scripts are run, job-dsl will attach multiple "actions" to the build. The current code seems to assume that there is only a single one.
To find the last generated objects, it's probably a simple change, maybe something like this:
Further, job-dsl needs to be made aware of previous invocations during the same build run.
Currently, it compares the "new items" against the items items from the first suitable previous run. Here's a simple idea:
GeneratedItems generatedItems = dslScriptLoader.runScripts(scriptRequests); mergeWithCurrentRun(generatedItems, run); // <-- this would be the only change Set<GeneratedJob> freshJobs = generatedItems.getJobs(); Set<GeneratedView> freshViews = generatedItems.getViews(); Set<GeneratedConfigFile> freshConfigFiles = generatedItems.getConfigFiles(); Set<GeneratedUserContent> freshUserContents = generatedItems.getUserContents();
One could simply pretend that a subsequent invocation also "generated" the items that were generated previously in the same run.
The last invocation's log output would then summarize everything that job-dsl did.
Finally, one could check whether a build action is already appened to the current run and replace it it instead, instead of unconditionally doing run.addAction:
This might affect
JENKINS-29784daspilker Thoughts?