Merge "Add zuul.project.src_dir variable" into feature/zuulv3
diff --git a/doc/source/user/jobs.rst b/doc/source/user/jobs.rst
index 5f36c30..4e1880a 100644
--- a/doc/source/user/jobs.rst
+++ b/doc/source/user/jobs.rst
@@ -205,6 +205,13 @@
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.
@@ -246,6 +253,12 @@
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).
diff --git a/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml b/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml
index cd343d0..f3ad414 100644
--- a/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml
+++ b/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml
@@ -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 }}"
diff --git a/zuul/executor/client.py b/zuul/executor/client.py
index 6d1a54f..e503f41 100644
--- a/zuul/executor/client.py
+++ b/zuul/executor/client.py
@@ -16,6 +16,7 @@
import gear
import json
import logging
+import os
import time
import threading
from uuid import uuid4
@@ -154,7 +155,9 @@
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 @@
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'):