From 4ea777ae66648144fb0449ca10d515cc3e03a237 Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Wed, 6 Feb 2019 15:30:12 +0100 Subject: [PATCH] Optionally silence git in mirror-workspace-git-repos Especially when using Github branch and push workflows repos can easily have hundreds of branches. The role mirror-workspace-git-repos which pushes them onto the node prints all of them in every build. This can get quite messy. Thus we need to optionally be able to silence the git push operation. This is done on purpose by the --quiet parameter instead of using no_log because this way errors are still logged normally and normal operation produces no log output for this task. Change-Id: Id77cc00972df9139e4544dd79954d91f4ab6b60b --- roles/mirror-workspace-git-repos/README.rst | 8 ++++++++ roles/mirror-workspace-git-repos/defaults/main.yaml | 1 + roles/mirror-workspace-git-repos/tasks/main.yaml | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 roles/mirror-workspace-git-repos/defaults/main.yaml diff --git a/roles/mirror-workspace-git-repos/README.rst b/roles/mirror-workspace-git-repos/README.rst index b6e4ed940..e2a1fdac7 100644 --- a/roles/mirror-workspace-git-repos/README.rst +++ b/roles/mirror-workspace-git-repos/README.rst @@ -4,3 +4,11 @@ This role uses git operations (unlike :zuul:role:`prepare-workspace` which uses rsync) to mirror the local prepared git repos to the remote nodes. This may be useful if the remote node already has a copy of some or all of the git repos. + +**Role Variables** + +.. zuul:rolevar:: mirror_workspace_quiet + :default: false + + If `true` git operations will be silenced and won't print every + changed reference. diff --git a/roles/mirror-workspace-git-repos/defaults/main.yaml b/roles/mirror-workspace-git-repos/defaults/main.yaml new file mode 100644 index 000000000..b59b6d6b5 --- /dev/null +++ b/roles/mirror-workspace-git-repos/defaults/main.yaml @@ -0,0 +1 @@ +mirror_workspace_quiet: false diff --git a/roles/mirror-workspace-git-repos/tasks/main.yaml b/roles/mirror-workspace-git-repos/tasks/main.yaml index 3cd81bf6f..82212d952 100644 --- a/roles/mirror-workspace-git-repos/tasks/main.yaml +++ b/roles/mirror-workspace-git-repos/tasks/main.yaml @@ -7,7 +7,7 @@ with_dict: "{{ zuul.projects }}" - name: Synchronize src repos to workspace directory - command: "git push --mirror git+ssh://{{ ansible_user }}@{{ ansible_host | ipwrap }}:{{ ansible_port }}/{{ ansible_user_dir }}/{{ item.value.src_dir}}" + command: "git push {% if mirror_workspace_quiet %}--quiet{% endif %} --mirror git+ssh://{{ ansible_user }}@{{ ansible_host | ipwrap }}:{{ ansible_port }}/{{ ansible_user_dir }}/{{ item.value.src_dir}}" args: chdir: "{{ zuul.executor.work_root }}/{{ item.value.src_dir }}" with_dict: "{{ zuul.projects }}" @@ -32,7 +32,7 @@ # Undo the config setting we did above git config --local --unset receive.denyCurrentBranch # checkout the branch matching the branch set up by the executor - git checkout {{ item.value.checkout }} + git checkout {% if mirror_workspace_quiet %}--quiet{% endif %} {{ item.value.checkout }} # put out a status line with the current HEAD echo "{{ item.value.canonical_name }} checked out to:" git log --pretty=oneline -1