Skip to content

Commit 7161032

Browse files
committed
[ansibletest] Add a branch for the git repo
The allows for setting the POD_ANSIBLE_GIT_BRANCH var to specify which branch to check out. The default behaviour is preserved i.e. clone the repo and use the default branch When the new env var is set, the specified branch is checked out in the cloned repo.
1 parent 8e4b7ab commit 7161032

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

container-images/tcib/base/ansible-tests/run_ansible.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ANSIBLE_FILE_EXTRA_VARS_PARAM="${ANSIBLE_FILE_EXTRA_VARS_PARAM:-}"
77
POD_ANSIBLE_PLAYBOOK="${POD_ANSIBLE_PLAYBOOK:-}"
88
POD_ANSIBLE_EXTRA_VARS="${POD_ANSIBLE_EXTRA_VARS:-}"
99
POD_ANSIBLE_GIT_REPO="${POD_ANSIBLE_GIT_REPO:-}"
10+
POD_ANSIBLE_GIT_BRANCH="${POD_ANSIBLE_GIT_BRANCH:-}"
1011

1112
# Check and set ansible debug verbosity
1213
ANSIBLE_DEBUG=""
@@ -17,6 +18,12 @@ fi
1718
# Clone the Ansible repository
1819
git clone "$POD_ANSIBLE_GIT_REPO" "$ANSIBLE_DIR"
1920

21+
if [[ -n "$POD_ANSIBLE_GIT_BRANCH" ]]; then
22+
pushd "$ANSIBLE_DIR"
23+
git fetch && git checkout --track origin/${POD_ANSIBLE_GIT_BRANCH}
24+
popd
25+
fi
26+
2027
# Handle extra vars file if provided
2128
if [[ -n "${POD_ANSIBLE_FILE_EXTRA_VARS:-}" ]]; then
2229
echo "$POD_ANSIBLE_FILE_EXTRA_VARS" > "$ANSIBLE_DIR/extra_vars.yaml"

0 commit comments

Comments
 (0)