Add example for variable expansion inside macros and jobs
Story: 2010588 Story: 2010963 Change-Id: Ifb51b267db3b32f380d571ce4bc71cb9662f895c
This commit is contained in:
parent
35a75d28e5
commit
081fcaa0d3
82
tests/yamlparser/job_fixtures/job-and-macro-expansions.xml
Normal file
82
tests/yamlparser/job_fixtures/job-and-macro-expansions.xml
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<displayName>sample-job</displayName>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<displayName>sample-job-template</displayName>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should be expanded: sample param value
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should be expanded: sample param value
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should be expanded: sample param value
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should not be expanded: {param}
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Should be expanded: sample param value
|
||||
</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
51
tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml
Normal file
51
tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml
Normal file
@ -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
|
@ -0,0 +1 @@
|
||||
echo Should be expanded: {param}
|
@ -0,0 +1 @@
|
||||
echo Should not be expanded: {param}
|
19
tests/yamlparser/job_fixtures/job_honor_defaults.xml
Normal file
19
tests/yamlparser/job_fixtures/job_honor_defaults.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo Build arch {arch}.</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
10
tests/yamlparser/job_fixtures/job_honor_defaults.yaml
Normal file
10
tests/yamlparser/job_fixtures/job_honor_defaults.yaml
Normal file
@ -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}."
|
Loading…
x
Reference in New Issue
Block a user