Add example for variable expansion inside macros and jobs

Story: 2010588
Story: 2010963
Change-Id: Ifb51b267db3b32f380d571ce4bc71cb9662f895c
This commit is contained in:
Vsevolod Fedorov 2023-11-13 10:50:23 +03:00
parent 940a4b65be
commit 009005c3bf
3 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</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 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 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>
</builders>
<publishers/>
<buildWrappers/>
</project>
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</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 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 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>
</builders>
<publishers/>
<buildWrappers/>
</project>

View File

@ -0,0 +1,46 @@
# 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
# macroses 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.inc
- builder:
name: builder-with-params
builders:
- shell: |
echo Should not be expanded: {{param}}
- shell: !include-raw-escape: job-and-macro-expansions.yaml.inc
- job:
name: sample-job
builders:
- builder-without-params
- builder-with-params:
param: sample unused param value
- shell: |
echo Should not be expanded: {param}
- shell: !include-raw: job-and-macro-expansions.yaml.inc
- job-template:
name: sample-job-template
builders:
- builder-without-params
- builder-with-params:
param: sample unused param value
- shell: |
echo Should not be expanded: {{param}}
- shell: !include-raw-escape: job-and-macro-expansions.yaml.inc
- project:
name: sample-project
param: sample unused param value
jobs:
- sample-job-template

View File

@ -0,0 +1 @@
echo Should not be expanded: {param}