Merge "docker-pull-image: Pull Docker image from Docker Hub/Registry"

This commit is contained in:
Zuul 2018-11-14 23:52:09 +00:00 committed by Gerrit Code Review
commit 3958ed5923
5 changed files with 72 additions and 0 deletions

View File

@ -4048,6 +4048,47 @@ def docker_build_publish(parse, xml_parent, data):
registry, registry_data, mappings, fail_required=True)
def docker_pull_image(registry, xml_parent, data):
"""yaml: docker-pull-image
Provides integration between Jenkins and Docker Hub, utilizing a
Docker Hub hook to trigger one (or more) Jenkins job(s).
Requires the Jenkins :jenkins-wiki:`CloudBees Docker Hub Notification
<CloudBees+Docker+Hub+Notification>`.
:arg str image: Image ID on DockerHub (default '')
:arg str docker-registry-url: URL to the Docker registry
you are using (default '')
:arg str credentials-id: Registry credentials (default '')
Minimal example:
.. literalinclude::
/../../tests/builders/fixtures/docker-pull-image-minimal.yaml
Full example:
.. literalinclude::
/../../tests/builders/fixtures/docker-pull-image-full.yaml
"""
docker_pull_image = XML.SubElement(
xml_parent, 'org.jenkinsci.plugins.registry.'
'notification.DockerPullImageBuilder')
docker_pull_image.set('plugin', 'dockerhub-notification')
registry = XML.SubElement(docker_pull_image, 'registry')
registry.set('plugin', 'docker-commons')
mapping = [
('image', 'image', ''),
]
helpers.convert_mapping_to_xml(
docker_pull_image, data, mapping, fail_required=False)
registry_mapping = [
('docker-registry-url', 'url', ''),
('credentials-id', 'credentialsId', ''),
]
helpers.convert_mapping_to_xml(
registry, data, registry_mapping, fail_required=False)
def build_name_setter(registry, xml_parent, data):
"""yaml: build-name-setter
Define Build Name Setter options which allows your build name to be

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<org.jenkinsci.plugins.registry.notification.DockerPullImageBuilder plugin="dockerhub-notification">
<registry plugin="docker-commons">
<url>https://index.docker.io/v1/</url>
<credentialsId>71e4f29c-162b-40d0-85d9-3ddfba2911a0</credentialsId>
</registry>
<image>test-image-id</image>
</org.jenkinsci.plugins.registry.notification.DockerPullImageBuilder>
</builders>
</project>

View File

@ -0,0 +1,5 @@
builders:
- docker-pull-image:
image: test-image-id
docker-registry-url: https://index.docker.io/v1/
credentials-id: 71e4f29c-162b-40d0-85d9-3ddfba2911a0

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<org.jenkinsci.plugins.registry.notification.DockerPullImageBuilder plugin="dockerhub-notification">
<registry plugin="docker-commons">
<url/>
<credentialsId/>
</registry>
<image/>
</org.jenkinsci.plugins.registry.notification.DockerPullImageBuilder>
</builders>
</project>

View File

@ -0,0 +1,2 @@
builders:
- docker-pull-image