Add support for CloudBees Docker Hub Notification Plugin
Change-Id: I1653c79c3abef9afa8157f3af04ee39a3e7a804e Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
parent
09f979a97f
commit
c067b01583
@ -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.
|
||||
|
16
tests/triggers/fixtures/dockerhub-notification-full.xml
Normal file
16
tests/triggers/fixtures/dockerhub-notification-full.xml
Normal 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>
|
6
tests/triggers/fixtures/dockerhub-notification-full.yaml
Normal file
6
tests/triggers/fixtures/dockerhub-notification-full.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
triggers:
|
||||
- dockerhub-notification:
|
||||
referenced-image: true
|
||||
repositories:
|
||||
- repo1
|
||||
- repo2
|
@ -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>
|
@ -0,0 +1,2 @@
|
||||
triggers:
|
||||
- dockerhub-notification
|
Loading…
Reference in New Issue
Block a user