demo-jenkins-config-as-code icon indicating copy to clipboard operation
demo-jenkins-config-as-code copied to clipboard

Groovy scripts with leading numbers to ensure execution order

Open avoidik opened this issue 6 years ago • 4 comments

Subj

avoidik avatar Oct 03 '17 10:10 avoidik

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

oleg-nenashev avatar Oct 03 '17 12:10 oleg-nenashev

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

reinholdfuereder avatar Apr 12 '19 11:04 reinholdfuereder

For instance let's imagine the case where we have the following files sorted by the logical order of execution

  1. base-config.groovy - we're applying basic configuration
  2. config-ldap.groovy - we're adding LDAP configuration
  3. 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.

  1. add-users.groovy - we're adding users to something that doesn't exist yet
  2. base-config.groovy
  3. config-ldap.groovy

By introducing a certain naming convention the required order of execution will be ensured, e.g.

  1. 01-config-ldap.groovy
  2. 02-base-config.groovy
  3. 03-add-users.groovy

Please correct me if I'm wrong

avoidik avatar Apr 12 '19 15:04 avoidik

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?

reinholdfuereder avatar Apr 13 '19 15:04 reinholdfuereder