diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 4b29366e5..ea76ffeed 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -5202,6 +5202,34 @@ def doxygen(registry, xml_parent, data): data.get('keep-all', False)).lower() +def docker_stop_container(registry, xml_parent, data): + """yaml: docker-stop-container + This plugin allows removing stopped docker containers. + It requires the :jenkins-wiki:`Docker build step plugin + `. + + :arg bool remove-stopped-containers: Boolean value to remove + stopped docker containers (default False) + + Minimal Example: + .. literalinclude:: /../../tests/ + publishers/fixtures/docker-stop-container-minimal.yaml + + Full Example: + .. literalinclude:: /../../tests/ + publishers/fixtures/docker-stop-container-full.yaml + """ + docker_stop_container = XML.SubElement(xml_parent, + 'com.nirima.jenkins.plugins.docker' + '.publisher.DockerPublisherControl') + docker_stop_container.set('plugin', 'docker-plugin') + mapping = [ + ('remove-stopped-containers', 'remove', False), + ] + helpers.convert_mapping_to_xml( + docker_stop_container, data, mapping, fail_required=False) + + def sitemonitor(registry, xml_parent, data): """yaml: sitemonitor This plugin checks the availability of an url. diff --git a/tests/publishers/fixtures/docker-stop-container-full.xml b/tests/publishers/fixtures/docker-stop-container-full.xml new file mode 100644 index 000000000..2ba955bbb --- /dev/null +++ b/tests/publishers/fixtures/docker-stop-container-full.xml @@ -0,0 +1,8 @@ + + + + + true + + + diff --git a/tests/publishers/fixtures/docker-stop-container-full.yaml b/tests/publishers/fixtures/docker-stop-container-full.yaml new file mode 100644 index 000000000..63ee0a0ef --- /dev/null +++ b/tests/publishers/fixtures/docker-stop-container-full.yaml @@ -0,0 +1,3 @@ +publishers: + - docker-stop-container: + remove-stopped-containers: true diff --git a/tests/publishers/fixtures/docker-stop-container-minimal.xml b/tests/publishers/fixtures/docker-stop-container-minimal.xml new file mode 100644 index 000000000..33cc1634b --- /dev/null +++ b/tests/publishers/fixtures/docker-stop-container-minimal.xml @@ -0,0 +1,8 @@ + + + + + false + + + diff --git a/tests/publishers/fixtures/docker-stop-container-minimal.yaml b/tests/publishers/fixtures/docker-stop-container-minimal.yaml new file mode 100644 index 000000000..d4df5f834 --- /dev/null +++ b/tests/publishers/fixtures/docker-stop-container-minimal.yaml @@ -0,0 +1,2 @@ +publishers: + - docker-stop-container