-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins 2.412, jobDsl plugin 1.87
I am playing with the Jenkins CasC plugin to make our systems more robust and easier to rollback in the event of failure/disaster.
I have setup the jobDsl seed job as described in the JCasC docs and it almost works fine. We have multiple applications so our jobDsl repo looks something like this:
jobDslRepo/ ├── APP1/ │ ├── BUILD/ │ │ ├── script1.groovy │ │ ├── script2.groovy │ │ └── directory.groovy │ ├── DEPLOY/ │ │ ├── script1.groovy │ │ ├── script2.groovy │ │ └── directory.groovy │ └── directory.groovy ├── APP2/ │ ├── BUILD/ │ │ ├── script1.groovy │ │ ├── script2.groovy │ │ └── directory.groovy │ ├── DEPLOY/ │ │ ├── script1.groovy │ │ ├── script2.groovy │ │ └── directory.groovy │ └── directory.groovy └── APP3/ ├── BUILD/ │ ├── script1.groovy │ ├── script2.groovy │ └── directory.groovy ├── DEPLOY/ │ ├── script1.groovy │ ├── script2.groovy │ └── directory.groovy └── directory.groovy
The directory.groovy file define a folder like this:
// This is an example of APP1/directory.groovy String F_ROOT = "APP1" folder(F_ROOT) { (other configuration here) }
Or, for child folders, something like this:
// This is an example of APP1/BUILD/directory.groovy String F_ROOT = "APP1/BUILD" folder(F_ROOT) { (other configuration here) } // This is dependent on the APP1 folder already existing.
Now the main issue is that it seems like the plugin is reading all these files in order, so the first file to be read is APP1/BUILD/script1.groovy. This file has a dependency on the APP1/BUILD directory being created already, so the seed job just fails immediately.
In order to get this to work, I need to change my targets() definition to search for
*/directory.groovy
to obtain all the top level directories, then I can change it back to what it was originally
(*/*.groovy, */*/*.groovy)
to read my remaining files.
I propose that the jobDsl plugin should read files descending the hierarchy and give precedence to any files that define a new folder() so that the seed job can create a very large amount of folders and jobs all at once, without failing due to a job definitions dependency on a parent or grandparent folder.