Issue
-
I am performing some actions on CloudBees CI via a Groovy script and would need to reload the instance configuration from disk programatically.
-
I am performing some actions on a job in CloudBees CI via a Groovy script and would need to reload the job configuration from disk programatically.
-
I am looking for an alternative to restarting the instance to pickup my changes on disk
-
I need to reload the instance configuration from disk from the command line.
-
I need to reload a particular job configuration from disk from the command line.
Resolution
Instance configuration
You can reload your CloudBees CI configuration from disk programmatically by either:
-
using the method
reload()
applied to your Jenkins instance from a Groovy script, i.e.:
jenkins.model.Jenkins.getInstance().reload()
-
running the following command from a console in a directory where the jenkins-cli has been downloaded:
java -jar jenkins-cli.jar -s <your-jenkins-url> --auth "<your-admin-username>:<your-admin-api-token>" reload
-
curling
<your-jenkins-url>/reload
. Please note, that the latter will need to be done as a POST authenticated action, and that the authentication will need to be performed via an API token, i.e.:
curl -X POST http://localhost:9090/reload -u "<your-admin-username>:<your-admin-api-token>"
Before reloading your instance’s configuration from disk, read What does Reload Configuration from Disk do? to understand how it might impact your on-going activity at the moment of the reload.
Job configuration
You can reload your job configuration from disk programmatically by either:
-
using the method
doDoReload()
applied to your job item. For instance, for a custom update center:
import com.cloudbees.plugins.updatecenter.UpdateCenter UpdateCenter myUC = jenkins.model.Jenkins.instance.getItemByFullName("<your-uc-name>", UpdateCenter.class) myUC.doDoReload()
-
running the following command from a console in a directory where the jenkins-cli has been downloaded:
java -jar jenkins-cli.jar -s <your-jenkins-url> --auth "<your-admin-username>:<your-admin-api-token>" doReload```
-
curling
<your-jenkins-url>/job/<your-job-name>/doReload
. Please note, that the latter will need to be done as a POST authenticated action, and that the authentication will need to be performed via an API token, i.e.:
curl -X POST <your-jenkins-url>/job/<your-job-name>/doReload -u "<your-admin-username>:<your-admin-api-token>"