From 40afe30e24a64bf753fd856cdca02654b8f84f13 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 16 Jun 2014 00:24:27 +0100 Subject: [PATCH] Added authentication details to build job command --- jenkins.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jenkins.py b/jenkins.py index 843313c..418fdad 100644 --- a/jenkins.py +++ b/jenkins.py @@ -21,6 +21,7 @@ import threading import time import webbrowser import urllib2 +import base64 import jenkinsapi from jenkinsapi.jenkins import Jenkins @@ -286,7 +287,12 @@ def _list_jobs(jobs): def _build_job(job): try: - urllib2.urlopen(jenkins_url + "/job/" + job + "/build") + request = urllib2.Request(jenkins_url + "/job/" + job + "/build"); + if username: + basicauth = base64.encodestring("%s:%s" %(username, password)).replace("\n", "") + request.add_header("Authorization", "Basic %s" %basicauth); + request.add_data("") + urllib2.urlopen(request) except Exception, e: prof.win_show(win_tag, "Failed to build " + job + ", see the logs.") prof.log_warning("Failed to build " + job + ": " + str(e))