fix(ci): Escape dollar signs for shell variables in Woodpecker
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Woodpecker interprets $ as variable substitution in YAML, so we need to
use $$ to escape it and pass a literal $ to the shell script.
Changed from a for loop to explicit function calls with escaped variables:
- Use $$ instead of $ for all shell variables
- Function-based approach for cleaner variable passing
- Each package explicitly called: link_package "stack-api" etc.
This fixes the variable expansion issue where ${package} was empty,
resulting in URLs like "container//-/link/stack" (double slash).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -278,18 +278,24 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- apk add --no-cache curl
|
- apk add --no-cache curl
|
||||||
- |
|
- |
|
||||||
for package in stack-api stack-web stack-postgres stack-openbao stack-orchestrator; do
|
link_package() {
|
||||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
PKG="$$1"
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
STATUS=$$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
||||||
"https://git.mosaicstack.dev/api/v1/packages/mosaic/container/${package}/-/link/stack")
|
-H "Authorization: token $$GITEA_TOKEN" \
|
||||||
if [ "$STATUS" = "201" ] || [ "$STATUS" = "204" ]; then
|
"https://git.mosaicstack.dev/api/v1/packages/mosaic/container/$$PKG/-/link/stack")
|
||||||
echo "✅ Linked ${package} to stack"
|
if [ "$$STATUS" = "201" ] || [ "$$STATUS" = "204" ]; then
|
||||||
elif [ "$STATUS" = "400" ]; then
|
echo "✅ Linked $$PKG to stack"
|
||||||
echo "✅ ${package} already linked (OK)"
|
elif [ "$$STATUS" = "400" ]; then
|
||||||
|
echo "✅ $$PKG already linked (OK)"
|
||||||
else
|
else
|
||||||
echo "❌ Warning: ${package} link returned $STATUS"
|
echo "❌ $$PKG link failed with status $$STATUS"
|
||||||
fi
|
fi
|
||||||
done
|
}
|
||||||
|
link_package "stack-api"
|
||||||
|
link_package "stack-web"
|
||||||
|
link_package "stack-postgres"
|
||||||
|
link_package "stack-openbao"
|
||||||
|
link_package "stack-orchestrator"
|
||||||
when:
|
when:
|
||||||
- branch: [main, develop]
|
- branch: [main, develop]
|
||||||
event: [push, manual, tag]
|
event: [push, manual, tag]
|
||||||
|
|||||||
Reference in New Issue
Block a user