Add zuul.project.src_dir variable

For ease of use in writing ad-hoc jobs, include a variable for the
directory on the nodes where the source code will be.

Change-Id: Idb7b3a14766497d7013e054fbe1279cc8809fdb9
This commit is contained in:
Monty Taylor 2017-08-08 15:32:06 -05:00
parent e6a2818158
commit 9e67bb7981
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
3 changed files with 21 additions and 2 deletions

View File

@ -202,6 +202,13 @@ of item.
The full canonical name of the project including hostname.
E.g., `git.example.com/org/project`.
.. var:: src_dir
The path to the source code on the remote host, relative
to the home dir of the remote user.
E.g., `src/git.example.com/org/project`.
.. var:: tenant
The name of the current Zuul tenant.
@ -243,6 +250,12 @@ of item.
The full canonical name of the project including hostname.
E.g., `git.example.com/org/project`.
.. var:: src_dir
The path to the source code on the remote host, relative
to the home dir of the remote user.
E.g., `src/git.example.com/org/project`.
.. var:: branch
The target branch of the change (without the `refs/heads/` prefix).

View File

@ -21,6 +21,7 @@
- zuul.project.name == 'org/project'
- zuul.project.canonical_hostname == 'review.example.com'
- zuul.project.canonical_name == 'review.example.com/org/project'
- zuul.project.src_dir == 'src/review.example.com/org/project'
- debug:
msg: "vartest secret {{ vartest_secret }}"

View File

@ -16,6 +16,7 @@ import copy
import gear
import json
import logging
import os
import time
import threading
from uuid import uuid4
@ -154,7 +155,9 @@ class ExecutorClient(object):
name=item.change.project.name,
short_name=item.change.project.name.split('/')[-1],
canonical_hostname=item.change.project.canonical_hostname,
canonical_name=item.change.project.canonical_name)
canonical_name=item.change.project.canonical_name,
src_dir=os.path.join('src', item.change.project.canonical_name),
)
zuul_params = dict(build=uuid,
buildset=item.current_build_set.uuid,
@ -186,7 +189,9 @@ class ExecutorClient(object):
name=i.change.project.name,
short_name=i.change.project.name.split('/')[-1],
canonical_hostname=i.change.project.canonical_hostname,
canonical_name=i.change.project.canonical_name)
canonical_name=i.change.project.canonical_name,
src_dir=os.path.join('src', i.change.project.canonical_name),
)
if hasattr(i.change, 'number'):
d['change'] = str(i.change.number)
if hasattr(i.change, 'patchset'):