diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index 4a24af382..59cef4fcb 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -1003,6 +1003,45 @@ def lockable_resources(registry, xml_parent, data): lockable_resources, data, mapping, fail_required=True) +def docker_container(registry, xml_parent, data): + """yaml: docker-container + Requires the Jenkins: :jenkins-wiki:`Docker Plugin`. + + :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) + :arg str additional-tag: Additional tag to apply to the docker slave + instance when committing it. (default '') + :arg bool push-on-success: Also push the resulting image when committing + the docker slave instance. (default false) + :arg bool clean-local-images: Clean images from the local daemon after + building. (default true) + + Minimal Example: + + .. literalinclude:: + /../../tests/properties/fixtures/docker-container-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: + /../../tests/properties/fixtures/docker-container-full.yaml + :language: yaml + """ + xml_docker = XML.SubElement( + xml_parent, 'com.nirima.jenkins.plugins.docker.DockerJobProperty') + + mapping = [ + ('commit-on-success', 'tagOnCompletion', False), + ('additional-tag', 'additionalTag', ''), + ('push-on-success', 'pushOnSuccess', False), + ('clean-local-images', 'cleanImages', True) + ] + helpers.convert_mapping_to_xml( + xml_docker, data, mapping, fail_required=True) + + class Properties(jenkins_jobs.modules.base.Base): sequence = 20 diff --git a/tests/properties/fixtures/docker-container-full.xml b/tests/properties/fixtures/docker-container-full.xml new file mode 100644 index 000000000..a5374675a --- /dev/null +++ b/tests/properties/fixtures/docker-container-full.xml @@ -0,0 +1,11 @@ + + + + + true + latest + true + true + + + diff --git a/tests/properties/fixtures/docker-container-full.yaml b/tests/properties/fixtures/docker-container-full.yaml new file mode 100644 index 000000000..1899de3cf --- /dev/null +++ b/tests/properties/fixtures/docker-container-full.yaml @@ -0,0 +1,6 @@ +properties: + - docker-container: + commit-on-success: true + additional-tag: latest + push-on-success: true + clean-local-images: true \ No newline at end of file diff --git a/tests/properties/fixtures/docker-container-minimal.xml b/tests/properties/fixtures/docker-container-minimal.xml new file mode 100644 index 000000000..756a7cc79 --- /dev/null +++ b/tests/properties/fixtures/docker-container-minimal.xml @@ -0,0 +1,11 @@ + + + + + false + + false + true + + + diff --git a/tests/properties/fixtures/docker-container-minimal.yaml b/tests/properties/fixtures/docker-container-minimal.yaml new file mode 100644 index 000000000..90e71f0f0 --- /dev/null +++ b/tests/properties/fixtures/docker-container-minimal.yaml @@ -0,0 +1,2 @@ +properties: + - docker-container \ No newline at end of file diff --git a/tests/properties/fixtures/docker-container-nondefault.xml b/tests/properties/fixtures/docker-container-nondefault.xml new file mode 100644 index 000000000..e66746618 --- /dev/null +++ b/tests/properties/fixtures/docker-container-nondefault.xml @@ -0,0 +1,11 @@ + + + + + true + my-hands-are-typing-words + true + false + + + diff --git a/tests/properties/fixtures/docker-container-nondefault.yaml b/tests/properties/fixtures/docker-container-nondefault.yaml new file mode 100644 index 000000000..74b418437 --- /dev/null +++ b/tests/properties/fixtures/docker-container-nondefault.yaml @@ -0,0 +1,6 @@ +properties: + - docker-container: + commit-on-success: true + additional-tag: my-hands-are-typing-words + push-on-success: true + clean-local-images: false \ No newline at end of file