casc reload groovy command breaks jobdsl plugin if executed by pipeline step load()
See original GitHub issueYour checklist for this issue
-
Jenkins version: 2.190.3
-
Plugin version: 1.34
-
OS: docker image based on jenkins/jenkins:lts
Description
If jobs section is present in jenkins.yaml, configuration reload fails, both via UI and groovy script. Jobs config works without any issues on init, but fails on reload. CASC_JENKINS_CONFIG is set to url.
Config example:
jobs:
- script: >
folder('xxx')
Error: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.plugin.JenkinsDslScriptLoader.customizeCompilerConfiguration() is applicable for argument types: (org.codehaus.groovy.control.CompilerConfiguration) values: [org.codehaus.groovy.control.CompilerConfiguration@67233c11]
Full trace: https://pastebin.com/0A2Mtz8z
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (10 by maintainers)
Top Results From Across the Web
jenkinsci/configuration-as-code-plugin - Gitter
When I load this groovyscript via a configmap it gets constantly reloaded and the ... the casc config and re-apply the jobdsl, or...
Read more >Job DSL plugin: Casc reload button works fine but not Groovy ...
The Groovy reload command works fine when there are NOT jobs or folders defined within yaml, so I think the script permissions and...
Read more >Configuration as Code - Jenkins
Click Reload existing configuration to load the local changes onto the Jenkins server. Verify the changes on the UI. When you have thoroughly...
Read more >Jenkins-as-Code Part I | Initial Setup - Karl Fischer
A pipeline definition is a groovy script which is loaded by a job ... It is read by the Jenkins jobDSL plugin to...
Read more >Understanding and implementing Pipeline as Code
The presence of the Jenkinsfile in the root of a repository makes it eligible for Jenkins to automatically manage and execute jobs based...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To be honest, that page is quite lacking some important details. Like example of Jenkins CLI command or mention that only system groovy script will work… Should I maybe just create PR for that? 😃
I was able to find the root of this issue: forgot to remove
load('reload.groovy')
step from test job created by jobdsl 🤦🏻♂️ so seed job and reload job were working correctly but then test job was built by branch indexing and breaking jobdsl plugin…Conclusion: using
load
pipeline step to run casc reload groovy command effectively breaks jobdsl plugin. Guess it’s a lack of permissions, but quite weird that it’s affecting jobdsl plugin in such way.P.S. Maybe it will be useful for someone, my configs for casc reload:
jobdsl for reload job:
declarative pipeline step to trigger reload:
required permissions in casc:
Do you have any recommendations on how to automatically reload it securely then?
I think this is all really just working around the fact that JCaC offers no native way to automatically sync configuration from an external (preferably private) repository. The lack of that makes it largely useless IMO, because users have to, each time they make changes, go to the JCasC page and point it to the correct location to pull configuration from. And from looking, I couldn’t personally find a way to POST the JCasC in any officially documented way. Paired with the difficulty involved in figuring out what to put in there in the first place, it hardly feels worth the effort of using
Maybe this rant would be best suited to exist in a separate feature request for JCasC, or someone could point out to my why/how the suggestion is insecure