summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs/builder.py
diff options
context:
space:
mode:
authorSorin Sbarnea <ssbarnea@redhat.com>2018-04-06 11:36:15 +0100
committerThanh Ha <zxiiro@linux.com>2018-04-06 10:01:09 -0400
commitcd90a7e2a548c0455d2495bfb35078d190ac9ed4 (patch)
treeaca4864a58c4916c774644c4b128ca3902b775e0 /jenkins_jobs/builder.py
parent7356ab2ffb2656f68ca5812320cb650e3b7f242b (diff)
downloadpython-jenkins-job-builder-cd90a7e2a548c0455d2495bfb35078d190ac9ed4.tar.gz
python-jenkins-job-builder-cd90a7e2a548c0455d2495bfb35078d190ac9ed4.tar.xz
python-jenkins-job-builder-cd90a7e2a548c0455d2495bfb35078d190ac9ed4.zip
Include view url in logs when possible
Makes view logging similar to job one so URLs are printed inside the logs. Also assured that URLs for both, views and jobs, are ending with slash as thats the what Jenkins expected format. Change-Id: Id34a25b47b4f584f07cc2dc2039cc1a49ab49038
Diffstat (limited to 'jenkins_jobs/builder.py')
-rw-r--r--jenkins_jobs/builder.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/jenkins_jobs/builder.py b/jenkins_jobs/builder.py
index abed1d40..421d097a 100644
--- a/jenkins_jobs/builder.py
+++ b/jenkins_jobs/builder.py
@@ -108,10 +108,20 @@ class JenkinsManager(object):
# returns job name or url based on config option
if self._jjb_config.builder['print_job_urls']:
return self._jjb_config.jenkins['url'] + \
- '/job/' + '/job/'.join(job_name.split('/'))
+ '/job/' + '/job/'.join(job_name.split('/')) + '/'
else:
return job_name
+ def _view_format(self, view_name):
+ # returns job name or url based on config option
+ if self._jjb_config.builder['print_job_urls']:
+ parts = view_name.split('/')
+ return self._jjb_config.jenkins['url'] + \
+ ''.join(['/job/' + item for item in parts[:-1]]) + \
+ '/view/' + parts[-1] + '/'
+ else:
+ return view_name
+
def update_job(self, job_name, xml):
if self.is_job(job_name):
logger.info("Reconfiguring jenkins job {0}".format(
@@ -376,10 +386,12 @@ class JenkinsManager(object):
def update_view(self, view_name, xml):
if self.is_view(view_name):
- logger.info("Reconfiguring jenkins view {0}".format(view_name))
+ logger.info("Reconfiguring jenkins view {0}".format(
+ self._view_format(view_name)))
self.jenkins.reconfig_view(view_name, xml)
else:
- logger.info("Creating jenkins view {0}".format(view_name))
+ logger.info("Creating jenkins view {0}".format(
+ self._view_format(view_name)))
self.jenkins.create_view(view_name, xml)
def update_views(self, xml_views, output=None, n_workers=None,