diff --git a/tests/yamlparser/job_fixtures/job-and-macro-expansions.xml b/tests/yamlparser/job_fixtures/job-and-macro-expansions.xml new file mode 100644 index 000000000..612523a4d --- /dev/null +++ b/tests/yamlparser/job_fixtures/job-and-macro-expansions.xml @@ -0,0 +1,82 @@ + + + + <!-- Managed by Jenkins Job Builder --> + false + sample-job + false + false + false + true + + + + + echo Should not be expanded: {param} + + + + echo Should not be expanded: {param} + + + + + + + + + + <!-- Managed by Jenkins Job Builder --> + false + sample-job-template + false + false + false + true + + + + + echo Should not be expanded: {param} + + + + echo Should not be expanded: {param} + + + + echo Should not be expanded: {param} + + + + echo Should be expanded: sample param value + + + + echo Should not be expanded: {param} + + + + echo Should be expanded: sample param value + + + + echo Should not be expanded: {param} + + + + echo Should be expanded: sample param value + + + + echo Should not be expanded: {param} + + + + echo Should be expanded: sample param value + + + + + + diff --git a/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml new file mode 100644 index 000000000..d52c8b2eb --- /dev/null +++ b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml @@ -0,0 +1,51 @@ +# Example for tickets: +# https://storyboard.openstack.org/#!/story/2010588 Expand macros even if called without arguments +# https://storyboard.openstack.org/#!/story/2010963 Expand jobs the same way as job templates are expanded + +# Demonstrate different style of variable expansion and inclusion tags for +# macros with and without parameters and for jobs versus job templates. + +- builder: + name: builder-without-params + builders: + - shell: | + echo Should not be expanded: {param} + - shell: !include-raw: job-and-macro-expansions.yaml.no-expand.inc + +- builder: + name: builder-with-params + builders: + - shell: | + echo Should not be expanded: {{param}} + - shell: | + echo Should be expanded: {param} + - shell: !include-raw-escape: job-and-macro-expansions.yaml.no-expand.inc + - shell: !include-raw: job-and-macro-expansions.yaml.expand.inc + +- job: + name: sample-job + display-name: sample-job + builders: + - shell: | + echo Should not be expanded: {param} + - shell: !include-raw: job-and-macro-expansions.yaml.no-expand.inc + +- job-template: + name: sample-job-template + display-name: sample-job-template + builders: + - builder-without-params + - builder-with-params: + param: sample param value + - shell: | + echo Should not be expanded: {{param}} + - shell: | + echo Should be expanded: {param} + - shell: !include-raw-escape: job-and-macro-expansions.yaml.no-expand.inc + - shell: !include-raw: job-and-macro-expansions.yaml.expand.inc + +- project: + name: sample-project + param: sample param value + jobs: + - sample-job-template diff --git a/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml.expand.inc b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml.expand.inc new file mode 100644 index 000000000..24a08d1c7 --- /dev/null +++ b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml.expand.inc @@ -0,0 +1 @@ +echo Should be expanded: {param} diff --git a/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml.no-expand.inc b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml.no-expand.inc new file mode 100644 index 000000000..077ccc23d --- /dev/null +++ b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml.no-expand.inc @@ -0,0 +1 @@ +echo Should not be expanded: {param} diff --git a/tests/yamlparser/job_fixtures/job_honor_defaults.xml b/tests/yamlparser/job_fixtures/job_honor_defaults.xml new file mode 100644 index 000000000..b9639469e --- /dev/null +++ b/tests/yamlparser/job_fixtures/job_honor_defaults.xml @@ -0,0 +1,19 @@ + + + + <!-- Managed by Jenkins Job Builder --> + false + false + false + false + true + + + + + echo Build arch {arch}. + + + + + diff --git a/tests/yamlparser/job_fixtures/job_honor_defaults.yaml b/tests/yamlparser/job_fixtures/job_honor_defaults.yaml new file mode 100644 index 000000000..70fe442b9 --- /dev/null +++ b/tests/yamlparser/job_fixtures/job_honor_defaults.yaml @@ -0,0 +1,10 @@ +# Variables in jobs are not expanded. + +- defaults: + name: global + arch: 'i386' + +- job: + name: sample-job + builders: + - shell: "echo Build arch {arch}."