Skip to content

Commit 730e22c

Browse files
xinredhatRoming22
authored andcommitted
fixed the issue that failed to get password from bitwarden server
1 parent dd8c056 commit 730e22c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ci/images/ci-runner/hack/bin/utils.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ open_bitwarden_session() {
3939
fi
4040

4141
login_status=$(bw login --check 2>&1)
42-
if [ "$login_status" = "You are not logged in." ]; then
43-
printf "Error while logging into Bitwarden.\n" >&2 | indent 2
42+
echo "$login_status"
43+
if [ ! "$login_status" = "You are logged in!" ]; then
44+
printf 'Error while logging into Bitwarden: %s \n' "$login_status" >&2 | indent 2
4445
return
4546
fi
4647

@@ -53,7 +54,18 @@ open_bitwarden_session() {
5354
get_password() {
5455
setx_off
5556
local itemid="$1"
56-
password=$(bw get password "$itemid" --session "$session")
57+
local retry=0
58+
echo "Fetching password from Bitwarden"
59+
while ! password=$(bw get password "$itemid" --session "$session" 2>/dev/null); do
60+
sleep 2
61+
retry=$((retry+1))
62+
if [ "$retry" -eq 5 ]; then
63+
printf "Error: passwords could not be retrieved.\n" >&2 | indent 2
64+
exit 1
65+
else
66+
printf "Retrying...\n" | indent 2
67+
fi
68+
done
5769
export password
5870
setx_on
5971
}

0 commit comments

Comments
 (0)