Skip to content

Instantly share code, notes, and snippets.

@garsue
Created January 25, 2013 16:44
Show Gist options
  • Save garsue/4635913 to your computer and use it in GitHub Desktop.
Save garsue/4635913 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#vim: fileencoding=utf-8
from __future__ import print_function, division, unicode_literals
import urllib2
"""
Hooking git events to execute build on jenkins.
DON'T FORGET TO GIVE PERMISSION.
"""
try:
# urllib2.urlopen('http://localhost:<port>/job/<project_name>/build?delay=0sec')
# urllib2.urlopen('http://localhost:<port>/jenkins/job/<project_name>/build?delay=0sec') when setting prefix
urllib2.urlopen('http://localhost:8080/jenkins/job/GraduationThesis/build?delay=0sec')
except urllib2.HTTPError as e:
print("Reason", e.reason)
except urllib2.URLError as e:
print("Response code:", e.code)
print("Reason", e.reason)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment