Merge "Expose useful job variables to inventory file"

This commit is contained in:
Zuul authored and Gerrit Code Review committed 2026-09-04 15:52:07 +00:00
commit b3bdfd9872
5 files changed
+39 -2

No files matched your search

+16
View File
@@ -1351,6 +1351,22 @@ The following variables related to the job are available:
git tags, these are simply free-form text fields that can be
used by the job for reporting or classification purposes.
.. var:: workspace_checkout
Whether the job performed a full checkout of projects in the workspace.
This value is taken from :attr:`job.workspace-checkout`.
.. var:: deduplicate
Whether Zuul considered deduplication for this job or not. The value
is taken from :attr:`job.deduplicate`.
.. var:: image_build_name
The name of the image build by this job (in case this is an image
build job (see :ref:`image-creation`)). The value is taken from
:attr:`job.image-build-name`.
.. var:: resources
A job using a container build resources has access to a
+3
View File
@@ -116,6 +116,9 @@ class TestInventoryGithub(TestInventoryBase):
self.assertEqual(z_vars['message'], 'QQ==')
self.assertEqual(z_vars['change_url'],
'https://github.com/org/project3/pull/1')
self.assertTrue(z_vars['workspace_checkout'])
self.assertEqual(z_vars['deduplicate'], 'auto')
self.assertEqual(z_vars['image_build_name'], None)
self.executor_server.release()
self.waitUntilSettled()
+10
View File
@@ -536,6 +536,16 @@ class TestLauncher(LauncherBaseTestCase):
upload_ids, itertools.repeat(RuntimeError)
))
# Validate that the image_build_name is exposed to the inventory
build = self.getBuildByName('build-debian-local-image')
inv_path = os.path.join(build.jobdir.root, 'ansible', 'inventory.yaml')
with open(inv_path, 'r') as f:
inventory = yaml.safe_load(f)
self.assertEqual(
inventory['all']['vars']['zuul']['image_build_name'],
'debian-local'
)
self.executor_server.release('build-debian-local-image')
self.waitUntilSettled()
self.assertHistory([
+7 -2
View File
@@ -1403,13 +1403,15 @@ class TestWeb(BaseTestWeb):
'timeout': None,
'post_timeout': None,
'jobtags': [],
'branch': 'master',
'projects': {},
'items': [],
'change_url': None,
'child_jobs': [],
'event_id': None,
'include_vars': [],
'workspace_checkout': True,
'deduplicate': 'auto',
'image_build_name': None,
},
'workspace_scheme': 'golang',
'workspace_checkout': True,
@@ -1508,7 +1510,10 @@ class TestWeb(BaseTestWeb):
'pre_timeout': None,
'timeout': None,
'post_timeout': None,
'voting': True}}
'voting': True,
'workspace_checkout': True,
'deduplicate': True,
'image_build_name': None}}
self.assertEqual(job_params, resp.json())
+3
View File
@@ -252,6 +252,9 @@ def zuul_params_from_job(job):
"timeout": job.timeout,
"post_timeout": job.post_timeout,
"jobtags": sorted(job.tags),
"workspace_checkout": job.workspace_checkout,
"image_build_name": job.image_build_name,
"deduplicate": job.deduplicate,
"_inheritance_path": list(job.inheritance_path),
}
if job.artifact_data: