diff options
20 files changed, 111 insertions, 20 deletions
diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index 8724b362..87b7139b 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -3555,7 +3555,9 @@ def docker_build_publish(parse, xml_parent, data): :arg bool skip-decorate: Do not decorate the build name. (default false) :arg bool skip-tag-latest: Do not tag this build as latest. (default false) :arg bool skip-push: Do not push. (default false) - :arg str file-path: Project root of Dockerfile. (default '') + :arg str file-path: Path of the Dockerfile. (default '') + :arg str build-context: Project root path for the build, defaults to the + workspace if not specified. (default '') Example: @@ -3575,6 +3577,7 @@ def docker_build_publish(parse, xml_parent, data): ('skip-tag-latest', 'skipTagLatest', False), ('skip-push', 'skipPush', False), ('file-path', 'dockerfilePath', ''), + ('build-context', 'buildContext', ''), ] convert_mapping_to_xml(db, data, mapping, fail_required=True) diff --git a/jenkins_jobs/modules/parameters.py b/jenkins_jobs/modules/parameters.py index bfcb30ca..b39e66c2 100644 --- a/jenkins_jobs/modules/parameters.py +++ b/jenkins_jobs/modules/parameters.py @@ -762,6 +762,27 @@ def maven_metadata_param(registry, xml_parent, data): XML.SubElement(pdef, 'password').text = data.get('repository-password', '') +def hidden_param(parser, xml_parent, data): + """yaml: hidden + Allows you to use parameters hidden from the build with parameter page. + Requires the Jenkins :jenkins-wiki:`Hidden Parameter Plugin + <Hidden+Parameter+Plugin>`. + + :arg str name: the name of the parameter + :arg str default: the default value of the parameter (optional) + :arg str description: a description of the parameter (optional) + + Example: + + .. literalinclude:: + /../../tests/parameters/fixtures/hidden-param001.yaml + :language: yaml + + """ + base_param(parser, xml_parent, data, True, + 'com.wangyin.parameter.WHideParameterDefinition') + + class Parameters(jenkins_jobs.modules.base.Base): sequence = 21 diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index 47fce9ef..b3bb04fa 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -39,7 +39,7 @@ from jenkins_jobs.errors import InvalidAttributeError from jenkins_jobs.errors import JenkinsJobsException from jenkins_jobs.errors import MissingAttributeError import jenkins_jobs.modules.base -from jenkins_jobs.modules.helpers import convert_mapping_to_xml +import jenkins_jobs.modules.helpers as helpers def builds_chain_fingerprinter(registry, xml_parent, data): @@ -638,7 +638,7 @@ def delivery_pipeline(registry, xml_parent, data): ('task', 'taskName', ''), ('description', 'descriptionTemplate', ''), ] - convert_mapping_to_xml(pipeline, data, mapping, fail_required=True) + helpers.convert_mapping_to_xml(pipeline, data, mapping, fail_required=True) def zeromq_event(registry, xml_parent, data): diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index f264b89f..c324197d 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1913,6 +1913,8 @@ def email_ext(registry, xml_parent, data): :arg bool pre-build: Send an email before the build (default false) :arg str presend-script: A Groovy script executed prior sending the mail. (default '') + :arg str postsend-script: A Goovy script executed after sending the email. + (default '') :arg bool save-output: Save email content to workspace (default false) :arg str matrix-trigger: If using matrix projects, when to trigger @@ -1990,6 +1992,8 @@ def email_ext(registry, xml_parent, data): 'attachments', '') XML.SubElement(emailext, 'presendScript').text = data.get( 'presend-script', '') + XML.SubElement(emailext, 'postsendScript').text = data.get( + 'postsend-script', '') XML.SubElement(emailext, 'attachBuildLog').text = str(data.get( 'attach-build-log', False)).lower() XML.SubElement(emailext, 'compressBuildLog').text = str(data.get( diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index 5f2f29b7..fcdf145f 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -871,6 +871,8 @@ def github_pull_request(registry, xml_parent, data): (optional) :arg string error-comment: comment to add to the PR on an errored job (optional) + :arg bool cancel-builds-on-update: cancel existing builds when a PR is + updated (optional) Example: @@ -956,9 +958,11 @@ def github_pull_request(registry, xml_parent, data): error_comment ) - # We want to have only one 'extensions' subelement, even if both status - # handling and comment handling is needed. - if requires_status or requires_job_comment: + cancel_builds_on_update = data.get('cancel-builds-on-update', False) + + # We want to have only one 'extensions' subelement, even if status + # handling, comment handling and other extensions are enabled. + if requires_status or requires_job_comment or cancel_builds_on_update: extensions = XML.SubElement(ghprb, 'extensions') # Both comment and status elements have this same type. Using a const is @@ -1028,6 +1032,11 @@ def github_pull_request(registry, xml_parent, data): error_comment) XML.SubElement(error_comment_elem, 'result').text = 'ERROR' + if cancel_builds_on_update: + XML.SubElement(extensions, + 'org.jenkinsci.plugins.ghprb.extensions.' + 'build.GhprbCancelBuildsOnUpdate') + def gitlab_merge_request(registry, xml_parent, data): """yaml: gitlab-merge-request diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 75579e34..f57aea20 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -1075,20 +1075,11 @@ def jclouds(registry, xml_parent, data): :arg bool stop-on-terminate: Whether or not to suspend instead of terminate the instance (default false). - Example:: + Example: + + .. literalinclude:: /../../tests/wrappers/fixtures/jclouds001.yaml + :language: yaml - wrappers: - - jclouds: - single-use: True - instances: - - jenkins-dev-slave: - cloud-name: mycloud1 - count: 1 - stop-on-terminate: True - - jenkins-test-slave: - cloud-name: mycloud2 - count: 2 - stop-on-terminate: False """ if 'instances' in data: buildWrapper = XML.SubElement( diff --git a/jenkins_jobs/modules/zuul.py b/jenkins_jobs/modules/zuul.py index 69de851d..224412ae 100644 --- a/jenkins_jobs/modules/zuul.py +++ b/jenkins_jobs/modules/zuul.py @@ -95,6 +95,9 @@ ZUUL_PARAMETERS = [ {'string': {'description': 'Patchset of triggering change', 'name': 'ZUUL_PATCHSET'}}, + {'string': + {'description': 'Zuul considered this job voting or not', + 'name': 'ZUUL_VOTING'}}, ] ZUUL_POST_PARAMETERS = [ diff --git a/test-requirements.txt b/test-requirements.txt index 4a502b24..50e4b305 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,5 @@ hacking>=0.5.6,<=10.1 coverage>=3.6 -discover fixtures python-subunit sphinx>=1.3.1 diff --git a/tests/builders/fixtures/docker-builder001.xml b/tests/builders/fixtures/docker-builder001.xml index bf08040c..5543bd26 100644 --- a/tests/builders/fixtures/docker-builder001.xml +++ b/tests/builders/fixtures/docker-builder001.xml @@ -11,6 +11,7 @@ <skipTagLatest>false</skipTagLatest> <skipPush>false</skipPush> <dockerfilePath>/tmp/</dockerfilePath> + <buildContext>/tmp/</buildContext> </com.cloudbees.dockerpublish.DockerBuilder> </builders> </project> diff --git a/tests/builders/fixtures/docker-builder001.yaml b/tests/builders/fixtures/docker-builder001.yaml index 14bbd580..0b6ea9e8 100644 --- a/tests/builders/fixtures/docker-builder001.yaml +++ b/tests/builders/fixtures/docker-builder001.yaml @@ -9,4 +9,5 @@ builders: skip-latest: false skip-tag: false file-path: '/tmp/' + build-context: '/tmp/' diff --git a/tests/parameters/fixtures/hidden-param001.xml b/tests/parameters/fixtures/hidden-param001.xml new file mode 100644 index 00000000..752c2803 --- /dev/null +++ b/tests/parameters/fixtures/hidden-param001.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <properties> + <hudson.model.ParametersDefinitionProperty> + <parameterDefinitions> + <com.wangyin.parameter.WHideParameterDefinition> + <name>FOO</name> + <description>A parameter named FOO, defaults to 'bar'</description> + <defaultValue>bar</defaultValue> + </com.wangyin.parameter.WHideParameterDefinition> + </parameterDefinitions> + </hudson.model.ParametersDefinitionProperty> + </properties> +</project> diff --git a/tests/parameters/fixtures/hidden-param001.yaml b/tests/parameters/fixtures/hidden-param001.yaml new file mode 100644 index 00000000..dc1c5a22 --- /dev/null +++ b/tests/parameters/fixtures/hidden-param001.yaml @@ -0,0 +1,5 @@ +parameters: + - hidden: + name: FOO + default: bar + description: A parameter named FOO, defaults to 'bar' diff --git a/tests/publishers/fixtures/email-ext001.xml b/tests/publishers/fixtures/email-ext001.xml index 2e62a61d..c4b92c74 100644 --- a/tests/publishers/fixtures/email-ext001.xml +++ b/tests/publishers/fixtures/email-ext001.xml @@ -164,6 +164,7 @@ <defaultContent>The build has finished</defaultContent> <attachmentsPattern>*/foo*.log</attachmentsPattern> <presendScript>cancel=true</presendScript> + <postsendScript>cancel=true</postsendScript> <attachBuildLog>false</attachBuildLog> <compressBuildLog>false</compressBuildLog> <saveOutput>true</saveOutput> diff --git a/tests/publishers/fixtures/email-ext001.yaml b/tests/publishers/fixtures/email-ext001.yaml index 8b6201af..2fa27aad 100644 --- a/tests/publishers/fixtures/email-ext001.yaml +++ b/tests/publishers/fixtures/email-ext001.yaml @@ -24,6 +24,7 @@ publishers: pre-build: true matrix-trigger: only-configurations presend-script: "cancel=true" + postsend-script: "cancel=true" save-output: true send-to: - developers diff --git a/tests/publishers/fixtures/email-ext002.xml b/tests/publishers/fixtures/email-ext002.xml index 835d883d..991f7b95 100644 --- a/tests/publishers/fixtures/email-ext002.xml +++ b/tests/publishers/fixtures/email-ext002.xml @@ -21,6 +21,7 @@ <defaultContent>The build has finished</defaultContent> <attachmentsPattern>*/foo*.log</attachmentsPattern> <presendScript/> + <postsendScript/> <attachBuildLog>true</attachBuildLog> <compressBuildLog>true</compressBuildLog> <saveOutput>false</saveOutput> diff --git a/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml b/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml index 5d0ad07a..6570bc5c 100644 --- a/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml +++ b/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml @@ -54,6 +54,7 @@ org2</orgslist> </org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage> </messages> </org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus> + <org.jenkinsci.plugins.ghprb.extensions.build.GhprbCancelBuildsOnUpdate/> </extensions> </org.jenkinsci.plugins.ghprb.GhprbTrigger> </triggers> diff --git a/tests/triggers/fixtures/github-pull-request-multiple-extensions.yaml b/tests/triggers/fixtures/github-pull-request-multiple-extensions.yaml index ca04b55e..2eb0ce8f 100644 --- a/tests/triggers/fixtures/github-pull-request-multiple-extensions.yaml +++ b/tests/triggers/fixtures/github-pull-request-multiple-extensions.yaml @@ -27,3 +27,4 @@ triggers: success-status: 'success status!' failure-status: 'failure status :(' error-status: 'error status?!' + cancel-builds-on-update: true diff --git a/tests/wrappers/fixtures/jclouds001.xml b/tests/wrappers/fixtures/jclouds001.xml new file mode 100644 index 00000000..3550ab1c --- /dev/null +++ b/tests/wrappers/fixtures/jclouds001.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <buildWrappers> + <jenkins.plugins.jclouds.compute.JCloudsBuildWrapper> + <instancesToRun> + <jenkins.plugins.jclouds.compute.InstancesToRun> + <templateName>jenkins-dev-slave</templateName> + <cloudName>mycloud1</cloudName> + <count>1</count> + <suspendOrTerminate>true</suspendOrTerminate> + </jenkins.plugins.jclouds.compute.InstancesToRun> + <jenkins.plugins.jclouds.compute.InstancesToRun> + <templateName>jenkins-test-slave</templateName> + <cloudName>mycloud2</cloudName> + <count>2</count> + <suspendOrTerminate>false</suspendOrTerminate> + </jenkins.plugins.jclouds.compute.InstancesToRun> + </instancesToRun> + </jenkins.plugins.jclouds.compute.JCloudsBuildWrapper> + <jenkins.plugins.jclouds.compute.JCloudsOneOffSlave/> + </buildWrappers> +</project> diff --git a/tests/wrappers/fixtures/jclouds001.yaml b/tests/wrappers/fixtures/jclouds001.yaml new file mode 100644 index 00000000..e08e4d8e --- /dev/null +++ b/tests/wrappers/fixtures/jclouds001.yaml @@ -0,0 +1,12 @@ + wrappers: + - jclouds: + single-use: True + instances: + - jenkins-dev-slave: + cloud-name: mycloud1 + count: 1 + stop-on-terminate: True + - jenkins-test-slave: + cloud-name: mycloud2 + count: 2 + stop-on-terminate: False diff --git a/tests/yamlparser/fixtures/template_override_project_level_defaults.xml b/tests/yamlparser/fixtures/template_override_project_level_defaults.xml index cbc94049..10807152 100644 --- a/tests/yamlparser/fixtures/template_override_project_level_defaults.xml +++ b/tests/yamlparser/fixtures/template_override_project_level_defaults.xml @@ -32,6 +32,7 @@ <defaultContent>$DEFAULT_CONTENT</defaultContent> <attachmentsPattern/> <presendScript/> + <postsendScript/> <attachBuildLog>false</attachBuildLog> <compressBuildLog>false</compressBuildLog> <saveOutput>false</saveOutput> |