Task: 47875

Story: 2010711
Search for included files relative to the current job first

Change-Id: I34a5743967bf7cbb8b464a0a36abad24180d61e4
Signed-off-by: Max Trunov <trunov_ms@taximaxim.ru>
This commit is contained in:
Vsevolod Fedorov 2023-12-04 10:48:31 +03:00
parent d9c10ec725
commit d741ea02c6
8 changed files with 72 additions and 2 deletions

View File

@ -248,7 +248,7 @@ class BaseYamlObject(metaclass=abc.ABCMeta):
return cls(loader.jjb_config, loader, loader.pos_from_node(node), value)
def __init__(self, jjb_config, loader, pos):
self._search_path = jjb_config.yamlparser["include_path"]
self._search_path = jjb_config.yamlparser["include_path"].copy()
if loader.source_dir:
# Loaded from a file, find includes beside it too.
self._search_path.append(loader.source_dir)

View File

@ -7,6 +7,6 @@ include_missing_path_in_j2_yaml.yaml:3:3: In job template 'sample-job'
include_missing_path_in_j2_yaml.yaml:5:15: In expanded !j2-yaml:
builders: !j2-yaml: |
^
<expanded j2-yaml>:2:5: File missing-file.sh does not exist in any of include directories: .,fixtures-dir,fixtures-dir
<expanded j2-yaml>:2:5: File missing-file.sh does not exist in any of include directories: .,fixtures-dir
!include: missing-file.sh
^

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>sample-job-1&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 sample_file 1
</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>sample-job-2&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 sample_file 2
</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

View File

@ -0,0 +1,13 @@
# https://storyboard.openstack.org/#!/story/2010711
# Bug: Wrong files adding by tag !include-raw(include-raw-escape, etc)
- job-template:
name: sample-job-1
description: sample-job-1
builders:
- shell: !include-raw-escape: sample_file.sh
- project:
name: sample-project-1
jobs:
- sample-job-1

View File

@ -0,0 +1 @@
echo sample_file 1

View File

@ -0,0 +1,13 @@
# https://storyboard.openstack.org/#!/story/2010711
# Bug: Wrong files adding by tag !include-raw(include-raw-escape, etc)
- job-template:
name: sample-job-2
description: sample-job-2
builders:
- shell: !include-raw-escape: sample_file.sh
- project:
name: sample-project-2
jobs:
- sample-job-2

View File

@ -0,0 +1 @@
echo sample_file 2

View File

@ -0,0 +1,2 @@
[job_builder]
recursive=True