diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index a3dded2c4..2d6d4683b 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -1100,6 +1100,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) @@ -1125,6 +1128,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