Conditional CasC

23 views
Skip to first unread message

domi

unread,
May 7, 2019, 2:30:04 AM5/7/19
to Jenkins Developers
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

nicolas de loof

unread,
May 7, 2019, 2:34:01 AM5/7/19
to jenkin...@googlegroups.com
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.

--
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 jenkinsci-de...@googlegroups.com.
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.

Oleg Nenashev

unread,
May 8, 2019, 3:06:20 AM5/8/19
to Jenkins Developers
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 <do...@fortysix.ch> 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 jenkin...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages