Add per-job URL patterns.

Add the option to specify the URL pattern left in Gerrit, per-job.

Example: a job that builds documentation and uploads it to a staging
site can leave the URL of the staging site iff the job succeeds.

Change-Id: I34841e61e9116fd8d4de7ac09d8f9cfe36fe78ec
Reviewed-on: https://review.openstack.org/18264
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
James E. Blair 2012-12-17 13:03:24 -08:00 committed by Jenkins
parent f2626eb384
commit 6aea36dd35
3 changed files with 37 additions and 6 deletions

View File

@ -18,6 +18,8 @@ Zuul has three configuration files:
Examples of each of the three files can be found in the etc/ directory
of the source distribution.
.. _zuulconf:
zuul.conf
~~~~~~~~~
@ -377,6 +379,18 @@ each job as it builds a list from the project specification.
**success-message (optional)**
The message that should be reported to Gerrit if the job fails.
**failure-pattern (optional)**
The URL that should be reported to Gerrit if the job fails.
Defaults to the Jenkins build URL or the url_pattern configured in
zuul.conf. May be supplied as a string pattern with substitutions
as described in url_pattern in :ref:`zuulconf`.
**success-pattern (optional)**
The URL that should be reported to Gerrit if the job succeeds.
Defaults to the Jenkins build URL or the url_pattern configured in
zuul.conf. May be supplied as a string pattern with substitutions
as described in url_pattern in :ref:`zuulconf`.
**hold-following-changes (optional)**
This is a boolean that indicates that changes that follow this
change in a dependent change pipeline should wait until this job

View File

@ -314,6 +314,8 @@ class Job(object):
self.name = name
self.failure_message = None
self.success_message = None
self.failure_pattern = None
self.success_pattern = None
self.parameter_function = None
self.hold_following_changes = False
self.voting = True
@ -329,6 +331,8 @@ class Job(object):
def copy(self, other):
self.failure_message = other.failure_message
self.success_message = other.success_message
self.failure_pattern = other.failure_pattern
self.success_pattern = other.success_pattern
self.parameter_function = other.parameter_function
self.hold_following_changes = other.hold_following_changes
self.voting = other.voting

View File

@ -114,6 +114,12 @@ class Scheduler(threading.Thread):
m = config_job.get('success-message', None)
if m:
job.success_message = m
m = config_job.get('failure-pattern', None)
if m:
job.failure_pattern = m
m = config_job.get('success-pattern', None)
if m:
job.success_pattern = m
m = config_job.get('hold-following-changes', False)
if m:
job.hold_following_changes = True
@ -706,16 +712,23 @@ class BasePipelineManager(object):
"rebase your change and upload a new patchset."
else:
if self.sched.config.has_option('zuul', 'url_pattern'):
pattern = self.sched.config.get('zuul', 'url_pattern')
url_pattern = self.sched.config.get('zuul', 'url_pattern')
else:
pattern = None
url_pattern = None
for job in self.pipeline.getJobs(changeish):
build = changeish.current_build_set.getBuild(job.name)
result = build.result
if result == 'SUCCESS' and job.success_message:
result = job.success_message
elif result == 'FAILURE' and job.failure_message:
result = job.failure_message
pattern = url_pattern
if result == 'SUCCESS':
if job.success_message:
result = job.success_message
if job.success_pattern:
pattern = job.success_pattern
elif result == 'FAILURE':
if job.failure_message:
result = job.failure_message
if job.failure_pattern:
pattern = job.failure_pattern
url = None
if build.url:
if pattern: