In my case I use Groovy hooks in order to define conditional CasC-logic. E.g. here: https://github.com/oleg-nenashev/demo-jenkins-config-as-code/blob/master/init_scripts/src/main/groovy/scripts/DevelopmentFolder.groovy#L34-L39 . Indeed Groovy Scripts could invoke JCasC API to apply YAML files if needed, so you would not need to use Groovy for the entire configuration, only for the conditional logic.
I agree with Nicolas that JCasC is not designed to support conditional configuration. It could be done in some way (e.g. by adding top-level section for conditions on a per-file basis), but it would complicate the syntax and the verification of the configs. BR, Oleg On Tuesday, May 7, 2019 at 8:34:01 AM UTC+2, nicolas de loof wrote: > > Why not just have two distinct docker images ? > Or a custom entrypoint to switch between configuration folders ? > > By design JCasC does not include any logic to keep being plain declarative. > > Le mar. 7 mai 2019 à 08:30, domi <[email protected] <javascript:>> a > écrit : > >> I’m not sure I missed something, is there any way to tell the CasC plugin >> load/ignore some configuration files? >> My use case is the following: I have a Dockerimage which contains all >> required configuration files, but in some cases I want to load a different >> security configuration (OAuth vs. Local). >> Is there any way I can do this? (Beside using groovy initscripts instead >> of the CasC configuration files) >> Thanks Domi >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Jenkins Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-dev/D7DA3592-8D8D-4EE5-AA96-D2B1221D7FAA%40fortysix.ch >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/52d36792-7f8c-4bdf-90e8-badad4f53bf8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
