How to reload the configuration Jenkins from the command line?

16,112

Solution 1

java -jar jenkins-cli.jar -noCertificateCheck -s https://jenkins.example.com:8443/jenkins/ reload-configuration

Solution 2

You can generate crumb:

curl -u 'admin:password' -X GET http://localhost:8090/crumbIssuer/api/json | jq

Response looks like:

{
  "_class": "hudson.security.csrf.DefaultCrumbIssuer",
  "crumb": "1348b504383211402ce562e0b46b3691",
  "crumbRequestField": "Jenkins-Crumb"
}

Then take crumb field value and use it in reload call:

curl -u 'admin:password' -X POST http://localhost:8090/reload -H 'Jenkins-Crumb: 1348b504383211402ce562e0b46b3691'

Share:
16,112
alexbel2404
Author by

alexbel2404

Updated on June 27, 2022

Comments

  • alexbel2404
    alexbel2404 almost 2 years

    I installed and configured Jenkins through the system configuration management (ansible). Through ansible create jobs, install modules and configure them. After installing and configuring the module authorization crowd2, to reload the config via http://localhost/jenkins/reload does not work, as required authorization. To generate an authorization token, you must first log in, but this is not desirable. Can I have root access to reload the config?

    P.S. Sorry for my English :)