Merge "Adding support for the Build Result Trigger plugin"

This commit is contained in:
Jenkins 2013-10-30 23:27:02 +00:00 committed by Gerrit Code Review
commit 4581b6b7a8
2 changed files with 68 additions and 0 deletions

View File

@ -368,6 +368,73 @@ def github_pull_request(parser, xml_parent, data):
XML.SubElement(ghprb, 'cron').text = data.get('cron', '')
def build_result(parser, xml_parent, data):
"""yaml: build-result
Configure jobB to monitor jobA build result. A build is scheduled if there
is a new build result matches your criteria (unstable, failure, ...)
Requires the Jenkins `BuildResultTrigger Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/BuildResultTrigger+Plugin>`_
:arg list groups: List groups of jobs and results to monitor for
:arg list jobs: The jobs to monitor (required)
:arg list results: Build results to monitor for (default success)
:arg bool combine: Combine all job information. A build will be
scheduled only if all conditions are met (default false)
:arg str cron: The cron syntax with which to poll the jobs for the
supplied result (default '')
Example::
triggers:
- build-result:
combine: true
cron: '* * * * *'
groups:
- jobs:
- foo
- example
results:
- unstable
- jobs:
- foo2
results:
- not-built
- aborted
"""
brt = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.'
'buildresulttrigger.BuildResultTrigger')
XML.SubElement(brt, 'spec').text = data.get('cron', '')
XML.SubElement(brt, 'combinedJobs').text = str(
data.get('combine', False)).lower()
jobs_info = XML.SubElement(brt, 'jobsInfo')
result_dict = {'success': 'SUCCESS',
'unstable': 'UNSTABLE',
'failure': 'FAILURE',
'not-built': 'NOT_BUILT',
'aborted': 'ABORTED'}
for group in data['groups']:
brti = XML.SubElement(jobs_info, 'org.jenkinsci.plugins.'
'buildresulttrigger.model.'
'BuildResultTriggerInfo')
if not group.get('jobs', []):
raise jenkins_jobs.errors.\
JenkinsJobsException('Jobs is missing and a required'
' element')
jobs_string = ",".join(group['jobs'])
XML.SubElement(brti, 'jobNames').text = jobs_string
checked_results = XML.SubElement(brti, 'checkedResults')
for result in group.get('results', ['success']):
if result not in result_dict:
raise jenkins_jobs.errors.\
JenkinsJobsException('Result entered is not valid,'
' must be one of: '
+ ', '.join(result_dict.keys()))
model_checked = XML.SubElement(checked_results, 'org.jenkinsci.'
'plugins.buildresulttrigger.model.'
'CheckedResult')
XML.SubElement(model_checked, 'checked').text = result_dict[result]
class Triggers(jenkins_jobs.modules.base.Base):
sequence = 50

View File

@ -163,6 +163,7 @@ setuptools.setup(
'tfs=jenkins_jobs.modules.scm:tfs',
],
'jenkins_jobs.triggers': [
'build-result=jenkins_jobs.modules.triggers:build_result',
'gerrit=jenkins_jobs.modules.triggers:gerrit',
'github=jenkins_jobs.modules.triggers:github',
('github-pull-request=jenkins_jobs.modules.triggers:'