Reputation: 405
I'm using the cloudbees-folder
plugin to organize the DSL job definitions in a folder structure. The structure of the repo is similar to this:
jobs/
- dev/
- other/
- job1/
- job2/
- folder.yml (dsl)
- web/
- job1/
- job2/
- folder.yml (dsl)
- test/
- other/
- job1/
- job2/
- folder.yml (dsl)
- web/
- job1/
- job2/
- folder.yml (dsl)
In the Casc Pipeline Demo shows the parent folder
script being configured as part of the pipepline job, however I'd like to separate the folder
script in to a separate config as illustrated in my directory structure above. In each of the dev
and test
directories, there are about a dozen directories, all of which follow the same pattern and are created successfully. However the web
directory does not have the folder.yml
config picked up first. This results in the following fatal error
2022-09-27 18:51:42.807+0000 [id=42] INFO j.j.plugin.JenkinsJobManagement#createOrUpdateConfig: createOrUpdateConfig for test/web/job1
2022-09-27 18:51:42.825+0000 [id=42] SEVERE jenkins.InitReactorRunner$1#onTaskFailed: Failed ConfigurationAsCode.init
javaposse.jobdsl.dsl.DslException: Could not create item, unknown parent path in "test/web/job1"
How can I guarantee the order of configs the JenkinsJobManagement#createOrUpdateConfig
uses so that the folders are always created before the job configs in the subdirectories are executed?
I previously tried prefixing the folder.yml
config name with numbers and underscores thinking there is some alphabetizing going on, but there doesn't seem to be a deterministic way the configs are being ordered.
Upvotes: 1
Views: 1692
Reputation: 405
Turns out when copy/pasting a dsl config, I did not rename a jobname so the parent path truly wasn't created. 🤦♂️
Upvotes: 2