Merge "Add support for CloudBees Docker Hub Notification Plugin"

This commit is contained in:
Zuul 2017-10-23 18:49:24 +00:00 committed by Gerrit Code Review
commit 695c34e991
5 changed files with 79 additions and 0 deletions

View File

@ -617,6 +617,53 @@ def gerrit(registry, xml_parent, data):
convert_mapping_to_xml(gtrig, data, message_mappings, fail_required=True)
def dockerhub_notification(registry, xml_parent, data):
"""yaml: dockerhub-notification
The job will get triggered when Docker Hub/Registry notifies
that Docker image(s) used in this job has been rebuilt.
Requires the Jenkins :jenkins-wiki:`CloudBees Docker Hub Notification
<CloudBees+Docker+Hub+Notification>`.
:arg bool referenced-image: Trigger the job based on repositories
used by any compatible docker plugin in this job. (default true)
:arg list repositories: Specified repositories to trigger the job.
(default [])
Minimal Example:
.. literalinclude::
/../../tests/triggers/fixtures/dockerhub-notification-minimal.yaml
:language: yaml
Full Example:
.. literalinclude::
/../../tests/triggers/fixtures/dockerhub-notification-full.yaml
:language: yaml
"""
dockerhub = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.'
'registry.notification.DockerHubTrigger')
dockerhub.set('plugin', 'dockerhub-notification')
option = XML.SubElement(dockerhub, 'options', {'class': 'vector'})
if data.get('referenced-image'):
XML.SubElement(option, 'org.jenkinsci.plugins.'
'registry.notification.'
'opt.impl.TriggerForAllUsedInJob')
repos = data.get('repositories', [])
if repos:
specified_names = XML.SubElement(option,
'org.jenkinsci.plugins.registry.'
'notification.opt.impl.'
'TriggerOnSpecifiedImageNames')
repo_tag = XML.SubElement(specified_names, 'repoNames')
for repo in repos:
XML.SubElement(repo_tag, 'string').text = repo
def pollscm(registry, xml_parent, data):
"""yaml: pollscm
Poll the SCM to determine if there has been a change.

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<org.jenkinsci.plugins.registry.notification.DockerHubTrigger plugin="dockerhub-notification">
<options class="vector">
<org.jenkinsci.plugins.registry.notification.opt.impl.TriggerForAllUsedInJob/>
<org.jenkinsci.plugins.registry.notification.opt.impl.TriggerOnSpecifiedImageNames>
<repoNames>
<string>repo1</string>
<string>repo2</string>
</repoNames>
</org.jenkinsci.plugins.registry.notification.opt.impl.TriggerOnSpecifiedImageNames>
</options>
</org.jenkinsci.plugins.registry.notification.DockerHubTrigger>
</triggers>
</project>

View File

@ -0,0 +1,6 @@
triggers:
- dockerhub-notification:
referenced-image: true
repositories:
- repo1
- repo2

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<org.jenkinsci.plugins.registry.notification.DockerHubTrigger plugin="dockerhub-notification">
<options class="vector"/>
</org.jenkinsci.plugins.registry.notification.DockerHubTrigger>
</triggers>
</project>

View File

@ -0,0 +1,2 @@
triggers:
- dockerhub-notification