demo-jenkins-config-as-code
demo-jenkins-config-as-code copied to clipboard
Groovy scripts with leading numbers to ensure execution order
Subj
It could be done for sure though I am thinking about a better approach with the dependency declaration once I https://github.com/librecores/librecores-ci/blob/master/init_scripts/src/main/groovy/GroovyBootstrap.groovy added to this repository
I think you already did it? See https://github.com/oleg-nenashev/demo-jenkins-config-as-code/blob/af1716a25217b12e4a3e0502f324402ea3c12127/init_scripts/src/main/groovy/GroovyBootstrap.groovy#L77
For instance let's imagine the case where we have the following files sorted by the logical order of execution
- base-config.groovy - we're applying basic configuration
- config-ldap.groovy - we're adding LDAP configuration
- add-users.groovy - we're adding users
If we're going to keep them as is the logical order will be kind of nonsense after scripts.sort().each {
being applied.
- add-users.groovy - we're adding users to something that doesn't exist yet
- base-config.groovy
- config-ldap.groovy
By introducing a certain naming convention the required order of execution will be ensured, e.g.
- 01-config-ldap.groovy
- 02-base-config.groovy
- 03-add-users.groovy
Please correct me if I'm wrong
Sorry for causing confusion:
- @avoidik I think your idea/suggestion makes perfectly sense
- and I had thought/hoped that @oleg-nenashev current implementation might already allow/support that?