From f3f2e3ea58de2cce3fb0a749326c498427474e88 Mon Sep 17 00:00:00 2001 From: tanhengyeow Date: Mon, 17 Sep 2018 21:56:55 +0800 Subject: [PATCH] docker-container: Improve support for more options Change-Id: I261959adcbba235f38fe4ac32b39a88ae96f636f Co-Authored-By: Anil Belur Signed-off-by: Tan Heng Yeow Signed-off-by: Anil Belur --- jenkins_jobs/modules/properties.py | 11 +++++++++++ tests/properties/fixtures/docker-container-full.xml | 4 ++++ tests/properties/fixtures/docker-container-full.yaml | 2 ++ .../properties/fixtures/docker-container-minimal.xml | 4 ++++ .../fixtures/docker-container-nondefault.xml | 4 ++++ 5 files changed, 25 insertions(+) diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index 8f1a1b025..513a15ab5 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -1081,6 +1081,9 @@ def docker_container(registry, xml_parent, data): """yaml: docker-container Requires the Jenkins: :jenkins-wiki:`Docker Plugin`. + :arg str docker-registry-url: URL of the Docker registry. (default '') + :arg str credentials-id: Credentials Id for the Docker registey. + (default '') :arg bool commit-on-success: When a job completes, the docker slave instance is committed with repository based on the job name and build number as tag. (default false) @@ -1106,6 +1109,14 @@ def docker_container(registry, xml_parent, data): xml_docker = XML.SubElement( xml_parent, 'com.nirima.jenkins.plugins.docker.DockerJobProperty') + registry = XML.SubElement(xml_docker, 'registry') + registry.set('plugin', 'docker-commons') + registry_mapping = [ + ('docker-registry-url', 'url', ''), + ('credentials-id', 'credentialsId', ''), + ] + helpers.convert_mapping_to_xml( + registry, data, registry_mapping, fail_required=False) mapping = [ ('commit-on-success', 'tagOnCompletion', False), ('additional-tag', 'additionalTag', ''), diff --git a/tests/properties/fixtures/docker-container-full.xml b/tests/properties/fixtures/docker-container-full.xml index a5374675a..36a671553 100644 --- a/tests/properties/fixtures/docker-container-full.xml +++ b/tests/properties/fixtures/docker-container-full.xml @@ -2,6 +2,10 @@ + + https://index.docker.io/v1/ + 71e4f29c-162b-40d0-85d9-3ddfba2911a0 + true latest true diff --git a/tests/properties/fixtures/docker-container-full.yaml b/tests/properties/fixtures/docker-container-full.yaml index b230e1bfb..c188cedb3 100644 --- a/tests/properties/fixtures/docker-container-full.yaml +++ b/tests/properties/fixtures/docker-container-full.yaml @@ -4,3 +4,5 @@ properties: additional-tag: latest push-on-success: true clean-local-images: true + docker-registry-url: https://index.docker.io/v1/ + credentials-id: 71e4f29c-162b-40d0-85d9-3ddfba2911a0 diff --git a/tests/properties/fixtures/docker-container-minimal.xml b/tests/properties/fixtures/docker-container-minimal.xml index 756a7cc79..ebb49d77b 100644 --- a/tests/properties/fixtures/docker-container-minimal.xml +++ b/tests/properties/fixtures/docker-container-minimal.xml @@ -2,6 +2,10 @@ + + + + false false diff --git a/tests/properties/fixtures/docker-container-nondefault.xml b/tests/properties/fixtures/docker-container-nondefault.xml index e66746618..d5e1d6269 100644 --- a/tests/properties/fixtures/docker-container-nondefault.xml +++ b/tests/properties/fixtures/docker-container-nondefault.xml @@ -2,6 +2,10 @@ + + + + true my-hands-are-typing-words true