Merge "Adding support for the Build Result Trigger plugin"
This commit is contained in:
commit
4581b6b7a8
@ -368,6 +368,73 @@ def github_pull_request(parser, xml_parent, data):
|
|||||||
XML.SubElement(ghprb, 'cron').text = data.get('cron', '')
|
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):
|
class Triggers(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 50
|
sequence = 50
|
||||||
|
|
||||||
|
1
setup.py
1
setup.py
@ -163,6 +163,7 @@ setuptools.setup(
|
|||||||
'tfs=jenkins_jobs.modules.scm:tfs',
|
'tfs=jenkins_jobs.modules.scm:tfs',
|
||||||
],
|
],
|
||||||
'jenkins_jobs.triggers': [
|
'jenkins_jobs.triggers': [
|
||||||
|
'build-result=jenkins_jobs.modules.triggers:build_result',
|
||||||
'gerrit=jenkins_jobs.modules.triggers:gerrit',
|
'gerrit=jenkins_jobs.modules.triggers:gerrit',
|
||||||
'github=jenkins_jobs.modules.triggers:github',
|
'github=jenkins_jobs.modules.triggers:github',
|
||||||
('github-pull-request=jenkins_jobs.modules.triggers:'
|
('github-pull-request=jenkins_jobs.modules.triggers:'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user