How to reload Jenkins configuration as code file from within groovy script? (Equivalent of clicking on "Reload existing configuration")
Reload Configuration from Disk simply refreshes Jenkins configuration files and directory structure. This command should be used when a change is made to Jenkins and its environment outside of the UI, such as editing config. xml files from the command line or moving jobs between folders from the command line.
The Jenkins Configuration as Code (JCasC) feature defines Jenkins configuration parameters in a human-readable YAML file that can be stored as source code. This essentially captures the configuration parameters and values that are used when configuring Jenkins from the web UI.
All your jobs is stored in config. xml files inside $JENKINS_HOME/jobs/<path_to_your_job> folders. So, you can just backup these config. xml files (or you can backup all Jenkins configuration by saving full $JENKINS_HOME folder).
Sample groovy script to reload configuration yaml file:
import io.jenkins.plugins.casc.ConfigurationAsCode;
ConfigurationAsCode.get().configure()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With