diff --git a/jenkins_jobs/modules/project_flow.py b/jenkins_jobs/modules/project_flow.py index 4ada48c29..0bd6d4bf1 100644 --- a/jenkins_jobs/modules/project_flow.py +++ b/jenkins_jobs/modules/project_flow.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2013 eNovance SAS # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,17 +22,20 @@ the :ref:`Job` definition. Requires the Jenkins `Build Flow Plugin. `_ -Example:: +In order to use it for job-template you have to escape the curly braces by +doubling them in the DSL: { -> {{ , otherwise it will be interpreted by the +python str.format() command. + +Job example: + + .. literalinclude:: + /../../tests/yamlparser/fixtures/project_flow_template001.yaml + +Job template example: + + .. literalinclude:: + /../../tests/yamlparser/fixtures/project_flow_template002.yaml - job: - name: test_job - project-type: flow - dsl: | - build("job1") - parallel ( - { build("job2a") }, - { build("job2b") } - ) """ import xml.etree.ElementTree as XML diff --git a/tests/yamlparser/fixtures/project_flow_template001.xml b/tests/yamlparser/fixtures/project_flow_template001.xml new file mode 100644 index 000000000..864a0e56c --- /dev/null +++ b/tests/yamlparser/fixtures/project_flow_template001.xml @@ -0,0 +1,20 @@ + + + build("job1") +parallel ( + { build("job2a") }, + { build("job2b") } +) + + + <!-- Managed by Jenkins Job Builder --> + false + false + false + false + true + + + + + diff --git a/tests/yamlparser/fixtures/project_flow_template001.yaml b/tests/yamlparser/fixtures/project_flow_template001.yaml new file mode 100644 index 000000000..65316ec3b --- /dev/null +++ b/tests/yamlparser/fixtures/project_flow_template001.yaml @@ -0,0 +1,9 @@ +- job: + name: test_job + project-type: flow + dsl: | + build("job1") + parallel ( + { build("job2a") }, + { build("job2b") } + ) diff --git a/tests/yamlparser/fixtures/project_flow_template002.xml b/tests/yamlparser/fixtures/project_flow_template002.xml new file mode 100644 index 000000000..ac1973e1c --- /dev/null +++ b/tests/yamlparser/fixtures/project_flow_template002.xml @@ -0,0 +1,32 @@ + + + build("job1") +parallel ( + { build("job2a") }, + { build("job2b") } +) +build("job2c") + + + <!-- Managed by Jenkins Job Builder --> + false + false + false + false + true + + + + + unittest + + + + + developer@nowhere.net + false + false + + + + diff --git a/tests/yamlparser/fixtures/project_flow_template002.yaml b/tests/yamlparser/fixtures/project_flow_template002.yaml new file mode 100644 index 000000000..32e93deb3 --- /dev/null +++ b/tests/yamlparser/fixtures/project_flow_template002.yaml @@ -0,0 +1,26 @@ +- job-template: + name: '{name}-unit-tests' + project-type: flow + dsl: | + build("job1") + parallel ( + {{ build("job2a") }}, + {{ build("job2b") }} + ) + build("job2c") + builders: + - shell: unittest + publishers: + - email: + recipients: '{mail-to}' + +- job-group: + name: '{name}-tests' + jobs: + - '{name}-unit-tests': + mail-to: developer@nowhere.net + +- project: + name: project-name + jobs: + - '{name}-tests'