Skip to content

Instantly share code, notes, and snippets.

@daicham daicham/jenkins.py
Created Jan 11, 2013

Embed
What would you like to do?
Request jenkins job by http on Python (Tested for Mercurial)
# usage:
# python jenkins.py jobname1, jobname2
import sys, httplib
JENKINS_HOST = 'localhost:8080'
URL = '/jenkins/job/%s/build?token=%s&cause=%s'
JENKINS_AUTH_TOKEN = 'token'
CAUSE='Requested%20by%20Python'
jenkins_job_ids = sys.argv
jenkins_job_ids.pop(0) # shift operation to reduce this command
for job_id in jenkins_job_ids:
http = httplib.HTTPConnection(JENKINS_HOST)
url = URL % (job_id, JENKINS_AUTH_TOKEN, CAUSE)
http.request('GET', url)
response = http.getresponse()
#print response.status, response.reason, url # debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.