Remote Triggering a Jenkins Job

20 Nov 2017 - automation python

All I wanted to do was trigger a job on another Jenkins instance. Here’s all the things I tried.

  • Tried out a plugin. This plugin does not work
  • Forked the plugin and applied some of the patches that have been contributed.
  • I wrote Python code to do it.
  • I wanted to get a “Build Cause” working and since that didn’t work on the first few tries, I added it as a parameter.
Pretty much what I kept hitting

It turns out that what I thought was working wasn’t actually working. I wasn’t passing parameters to my remote job. It was using the defaults. The fix for this problem is the most hilarious that I’ve seen. Turns out if you use the crumbs API and Jenkins auth, you don’t need the token. This was a bit of a lovely discovery after all this pain.

Now I need to figure out how to follow the Jenkins job, i.e. get the console output on remote Jenkins in real time. I found a python script that does exactly that. I tested it and it works.