Use zuul_workspace_root for prepare/mirror workspace roles
Use zuul_workspace_root as the destination folder for preparing and mirroring the workspace, which points to ansible_user_dir by default. (As is currently the case). The override of this variable can be useful when using a static node with multiple slots to use a separate workspace for each slot. Change-Id: If50abc7ccc2dfb6f4ea9f9d5c6a5091ff6967aef
This commit is contained in:
parent
258add7bb4
commit
7f400a0d32
@ -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.
|
||||
|
@ -1 +1,2 @@
|
||||
mirror_workspace_quiet: false
|
||||
zuul_workspace_root: "{{ ansible_user_dir }}"
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -1 +1,2 @@
|
||||
cached_repos_root: /opt/git
|
||||
zuul_workspace_root: "{{ ansible_user_dir }}"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user