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

Change-Id: I66e638564605fd25504b6e06524a26f778880f06
Co-Authored-By: Anil Belur <askb23@gmail.com>
Signed-off-by: Tan Heng Yeow <E0032242@u.nus.edu>
Signed-off-by: Anil Belur <askb23@gmail.com>
This commit is contained in:
tanhengyeow 2018-09-17 01:18:03 +08:00 committed by Thanh Ha (zxiiro)
parent 539d13e816
commit b7ee539bc5
5 changed files with 72 additions and 0 deletions

View File

@ -4019,6 +4019,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