From 4bddf4c6ee7912d69f61eacccf27e52eaf3c95c3 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sat, 20 Dec 2014 09:03:18 +0530 Subject: [PATCH] Add example to demonstrate flow plugin for job-template Change-Id: I7bacce4f495989f8b37d6fc6b1bd773326e83b57 --- jenkins_jobs/modules/project_flow.py | 24 ++++++++------ .../fixtures/project_flow_template001.xml | 20 ++++++++++++ .../fixtures/project_flow_template001.yaml | 9 ++++++ .../fixtures/project_flow_template002.xml | 32 +++++++++++++++++++ .../fixtures/project_flow_template002.yaml | 26 +++++++++++++++ 5 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 tests/yamlparser/fixtures/project_flow_template001.xml create mode 100644 tests/yamlparser/fixtures/project_flow_template001.yaml create mode 100644 tests/yamlparser/fixtures/project_flow_template002.xml create mode 100644 tests/yamlparser/fixtures/project_flow_template002.yaml 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'