diff --git a/roles/test-mirror-workspace-git-repos/README.rst b/roles/test-mirror-workspace-git-repos/README.rst index e2a1fdac7..3c32f2392 100644 --- a/roles/test-mirror-workspace-git-repos/README.rst +++ b/roles/test-mirror-workspace-git-repos/README.rst @@ -12,3 +12,8 @@ some or all of the git repos. If `true` git operations will be silenced and won't print every changed reference. + +.. zuul:rolevar:: zuul_workspace_root + :default: "{{ ansible_user_dir }}" + + The root of the workspace in which the repos are mirrored. diff --git a/roles/test-mirror-workspace-git-repos/defaults/main.yaml b/roles/test-mirror-workspace-git-repos/defaults/main.yaml index b59b6d6b5..fa348b50a 100644 --- a/roles/test-mirror-workspace-git-repos/defaults/main.yaml +++ b/roles/test-mirror-workspace-git-repos/defaults/main.yaml @@ -1 +1,2 @@ mirror_workspace_quiet: false +zuul_workspace_root: "{{ ansible_user_dir }}" diff --git a/roles/test-mirror-workspace-git-repos/tasks/main.yaml b/roles/test-mirror-workspace-git-repos/tasks/main.yaml index a782f6101..54398b22c 100644 --- a/roles/test-mirror-workspace-git-repos/tasks/main.yaml +++ b/roles/test-mirror-workspace-git-repos/tasks/main.yaml @@ -3,7 +3,7 @@ name: receive.denyCurrentBranch value: ignore scope: local - repo: "{{ ansible_user_dir }}/{{ zj_project.value.src_dir }}" + repo: "{{ zuul_workspace_root }}/{{ zj_project.value.src_dir }}" with_dict: "{{ zuul.projects }}" loop_control: loop_var: zj_project @@ -11,9 +11,9 @@ - name: Synchronize src repos to workspace directory command: |- {% if ansible_connection == "kubectl" %} - git push {% if mirror_workspace_quiet %}--quiet{% endif %} --mirror "ext::kubectl --context {{ zuul.resources[inventory_hostname].context }} -n {{ zuul.resources[inventory_hostname].namespace }} exec -i {{ zuul.resources[inventory_hostname].pod }} -- %S {{ ansible_user_dir }}/{{ zj_project.value.src_dir }}" + git push {% if mirror_workspace_quiet %}--quiet{% endif %} --mirror "ext::kubectl --context {{ zuul.resources[inventory_hostname].context }} -n {{ zuul.resources[inventory_hostname].namespace }} exec -i {{ zuul.resources[inventory_hostname].pod }} -- %S {{ zuul_workspace_root }}/{{ zj_project.value.src_dir }}" {% else %} - git push {% if mirror_workspace_quiet %}--quiet{% endif %} --mirror git+ssh://{{ ansible_user }}@{{ ansible_host | ipwrap }}:{{ ansible_port }}/{{ ansible_user_dir }}/{{ zj_project.value.src_dir }} + git push {% if mirror_workspace_quiet %}--quiet{% endif %} --mirror git+ssh://{{ ansible_user }}@{{ ansible_host | ipwrap }}:{{ ansible_port }}/{{ zuul_workspace_root }}/{{ zj_project.value.src_dir }} {% endif %} args: chdir: "{{ zuul.executor.work_root }}/{{ zj_project.value.src_dir }}" @@ -52,7 +52,7 @@ echo "{{ zj_project.value.canonical_name }} checked out to:" git log --pretty=oneline -1 args: - chdir: "{{ ansible_user_dir }}/{{ zj_project.value.src_dir }}" + chdir: "{{ zuul_workspace_root }}/{{ zj_project.value.src_dir }}" with_dict: "{{ zuul.projects }}" loop_control: loop_var: zj_project diff --git a/roles/test-prepare-workspace-git/README.rst b/roles/test-prepare-workspace-git/README.rst index e1e47118e..4e23c5761 100644 --- a/roles/test-prepare-workspace-git/README.rst +++ b/roles/test-prepare-workspace-git/README.rst @@ -15,3 +15,8 @@ The cached repos need to be placed using the canonical name under the :default: /opt/git The root of the cached repos. + +.. zuul:rolevar:: zuul_workspace_root + :default: "{{ ansible_user_dir }}" + + The root of the workspace in which the repos are mirrored. diff --git a/roles/test-prepare-workspace-git/defaults/main.yaml b/roles/test-prepare-workspace-git/defaults/main.yaml index b0c54a382..032db3c2a 100644 --- a/roles/test-prepare-workspace-git/defaults/main.yaml +++ b/roles/test-prepare-workspace-git/defaults/main.yaml @@ -1 +1,2 @@ cached_repos_root: /opt/git +zuul_workspace_root: "{{ ansible_user_dir }}" diff --git a/roles/test-prepare-workspace-git/tasks/main.yaml b/roles/test-prepare-workspace-git/tasks/main.yaml index 0ebcadcd1..839dbdb04 100644 --- a/roles/test-prepare-workspace-git/tasks/main.yaml +++ b/roles/test-prepare-workspace-git/tasks/main.yaml @@ -7,16 +7,16 @@ if [ -d "{{ cached_repos_root }}/{{ zj_project.canonical_name }}" ] ; then # We do a bare clone here first so that we skip creating a working # copy that will be overwritten later anyway. - git clone --bare {{ cached_repos_root }}/{{ zj_project.canonical_name }} {{ ansible_user_dir }}/{{ zj_project.src_dir }}/.git + git clone --bare {{ cached_repos_root }}/{{ zj_project.canonical_name }} {{ zuul_workspace_root }}/{{ zj_project.src_dir }}/.git else - git init {{ ansible_user_dir }}/{{ zj_project.src_dir }} + git init {{ zuul_workspace_root }}/{{ zj_project.src_dir }} fi - cd {{ ansible_user_dir }}/{{ zj_project.src_dir }} + cd {{ zuul_workspace_root }}/{{ zj_project.src_dir }} git config --local --bool core.bare false git remote -v | grep origin && git remote rm origin || true git remote add origin file:///dev/null args: - creates: "{{ ansible_user_dir }}/{{ zj_project.src_dir }}" + creates: "{{ zuul_workspace_root }}/{{ zj_project.src_dir }}" with_items: "{{ zuul.projects.values() | list }}" loop_control: loop_var: zj_project