11

Jenkins jobs have config.xml files that store the configuration of that job.

I have a "job manager" job that modifies the configuration of other jobs, but I can't seem to get it to acknowledge the new configuration without restarting Jenkins.

The jenkins-cli.jar command line tool strangely doesn't seem to have an option for this action.

It is possible to edit the configuration through the web interface, and have that save/acknowledged without a restart, so it doesn't seem that it would be a technical impossibility.

My best try was to try and post to the same address that the web interface does

wget --post-file=config.xml --user=joe.shmoe --password=secret01 \
     --no-check-certificate                                      \
     https://jenkins.company.com/job/myProject/config.xml

...but I get a 403 despite using valid credentials (copy pasted to ensure no typos)

Anyone have any ideas or know something simple that I'm missing?

Catskul
  • 1,839
  • 4
  • 20
  • 23
  • holy crap. THAT ACTUALLY WORKS !!! (with the authentication fixed as Catskul suggests below, or in my case with no auth) I've been looking for this technique for hours now... – Dave Dopson Nov 08 '11 at 02:14

2 Answers2

8

It turns out the crutial info seems to be wget's "--auth-no-challenge" option which apparently is for obscure webserver configurations like Jenkins that don't follow expected protocol:

wget --auth-no-challenge --user=joe.shmoe --password=secret  \
     --post-file=config.xml --no-check-certificate           \
     https://jenkins.company.com/job/myProject/config.xml
Catskul
  • 1,839
  • 4
  • 20
  • 23
4

I prefer curl....

curl "http://localhost:18080/jenkins/job/npm-package-aaa/config.xml" -si --data-binary "$XML" -H "Content-Type: text/xml" 
Dave Dopson
  • 241
  • 1
  • 4