| [Originally posted on the associated GitHub issue, replicating here for visibility.] I have personally worked around this by applying CasC configs through a job, and disabling CasC for Jenkins startup by pointing it to an empty file. That is, I have a job that does a SCM checkout, and then runs something like this as a system-groovy script (from the groovy plugin):
import jenkins.model.GlobalConfiguration
import io.jenkins.plugins.casc.ConfigurationAsCode
import io.jenkins.plugins.casc.CasCGlobalConfig
def workspacePath = build.environment.WORKSPACE
def jcascConfig = GlobalConfiguration.all().get(CasCGlobalConfig.class)
try {
jcascConfig.setConfigurationPath(workspacePath)
jcascConfig.save()
ConfigurationAsCode.get().configure()
} finally {
jcascConfig.setConfigurationPath("${workspacePath}/empty.yaml")
jcascConfig.save()
}
(Note that below CasC version 1.20, you need to have at least one setting in empty.yaml, a completely empty file generates a null pointer exception.) |