From cf1ae5235b80e943fce4fe9ae349eae77851b738 Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Mon, 5 Mar 2018 23:19:39 +0000 Subject: [PATCH] Make the task that remove the remote idempotent The current implementation of the task is not idempotent. That's fine in CI but when running locally it forces a cleanup of the environment every time. Change-Id: Ifdb573bc09ddb2d39674218e9f631e8c15f936cb --- roles/use-cached-repos/tasks/main.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/use-cached-repos/tasks/main.yaml b/roles/use-cached-repos/tasks/main.yaml index 55ceff0d07..4456db7093 100644 --- a/roles/use-cached-repos/tasks/main.yaml +++ b/roles/use-cached-repos/tasks/main.yaml @@ -31,7 +31,8 @@ - skip_ansible_lint - name: Remove origin from local git repos - command: "git remote rm origin" + # To be idempotent, remove origin only if it's found in the local list. + shell: "git remote -v | grep origin && git remote rm origin || true" args: chdir: "{{ ansible_user_dir }}/{{ item.src_dir}}" with_items: "{{ zuul.projects.values() | list }}"