-
Notifications
You must be signed in to change notification settings - Fork 1
BUILD-11961 Use default Vault URL for Maven Artifactory secrets #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9c64811
4d13a56
82a3631
886393d
d667d1e
54a2cf4
79e8643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/bin/bash | ||
| # Wait until a SaaS-minted Artifactory token is accepted by an edge node. | ||
| # | ||
| # /api/system/ping is anonymous; use a protected storage API that validates the token. | ||
| # | ||
| # Required environment variables: | ||
| # - ARTIFACTORY_URL: Artifactory base URL (…/artifactory) | ||
| # - ARTIFACTORY_USERNAME: Artifactory username | ||
| # - ARTIFACTORY_ACCESS_TOKEN: Artifactory access token | ||
| # | ||
| # Optional: | ||
| # - REPOX_URL: Instance URL used to skip the wait for SaaS (jfrog.io) | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPOX_URL="${REPOX_URL:-${ARTIFACTORY_URL:-}}" | ||
| if [[ "$REPOX_URL" == *jfrog.io* ]]; then | ||
| echo "Skipping token sync wait for SaaS Repox ($REPOX_URL)" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ -z "${ARTIFACTORY_URL:-}" || -z "${ARTIFACTORY_USERNAME:-}" || -z "${ARTIFACTORY_ACCESS_TOKEN:-}" ]]; then | ||
| echo "::error title=Missing Artifactory credentials::Cannot wait for token sync without credentials" | ||
| exit 1 | ||
| fi | ||
|
|
||
| check_url="${ARTIFACTORY_URL%/}/api/storage/sonarsource-qa" | ||
| max_attempts=60 | ||
| sleep_seconds=5 | ||
| attempt=0 | ||
|
|
||
| echo "Waiting for Artifactory token federation sync at $check_url (up to $((max_attempts * sleep_seconds))s)" | ||
|
|
||
| while true; do | ||
| attempt=$((attempt + 1)) | ||
| http_code="$(curl -sS -o /dev/null -w '%{http_code}' \ | ||
| -u "${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}" \ | ||
| "$check_url" || echo "000")" | ||
|
Comment on lines
+36
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Quality: curl failure appends duplicate http_code outputOn a connection failure curl still emits its Was this helpful? React with 👍 / 👎 |
||
|
|
||
| if [[ "$http_code" == "200" ]]; then | ||
| echo "Artifactory accepted credentials after ${attempt} attempt(s) (HTTP 200)" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if (( attempt >= max_attempts )); then | ||
| echo "::error title=Artifactory token sync timeout::Credentials were not accepted by $check_url" \ | ||
| "within $((max_attempts * sleep_seconds))s (last HTTP ${http_code})" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Attempt ${attempt}/${max_attempts}: HTTP ${http_code}, retrying in ${sleep_seconds}s..." | ||
| sleep "$sleep_seconds" | ||
| done | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Quality: curl retry lacks connect/max timeout
The polling curl has no --connect-timeout/--max-time, so a hung TCP connection to the edge node would stall an iteration indefinitely rather than counting as a failed attempt, defeating the 5-minute bound. Add
--connect-timeout 5 --max-time 15to keep each attempt time-boxed.Bound each curl attempt so a stalled connection can't hang the loop.:
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎