fix(provision): use $VAR instead of ${VAR} to avoid Woodpecker interpolation

Woodpecker performs compile-time substitution on ${...} patterns,
replacing pipeline variables with empty strings. Using $VAR without
braces lets the shell evaluate them at runtime.
This commit is contained in:
Viktor Barzin 2026-03-17 23:58:46 +00:00
parent fd130971aa
commit 0a05343d86

View file

@ -13,15 +13,15 @@ steps:
image: alpine image: alpine
commands: commands:
- | - |
if [ -z "${CI_PIPELINE_VARIABLE_USERNAME}" ] || [ -z "${CI_PIPELINE_VARIABLE_EMAIL}" ]; then if [ -z "$CI_PIPELINE_VARIABLE_USERNAME" ] || [ -z "$CI_PIPELINE_VARIABLE_EMAIL" ]; then
echo "ERROR: USERNAME and EMAIL variables are required" echo "ERROR: USERNAME and EMAIL variables are required"
echo "Trigger with: POST /api/repos/{id}/pipelines {branch:master, variables:{USERNAME:x, EMAIL:y}}" echo "Trigger with: POST /api/repos/{id}/pipelines {branch:master, variables:{USERNAME:x, EMAIL:y}}"
exit 1 exit 1
fi fi
echo "Provisioning user: ${CI_PIPELINE_VARIABLE_USERNAME} (${CI_PIPELINE_VARIABLE_EMAIL})" echo "Provisioning user: $CI_PIPELINE_VARIABLE_USERNAME ($CI_PIPELINE_VARIABLE_EMAIL)"
# Write vars to shared file for subsequent steps # Write vars to shared file for subsequent steps
echo "export PROVISION_USERNAME=${CI_PIPELINE_VARIABLE_USERNAME}" > .provision-env echo "export PROVISION_USERNAME=$CI_PIPELINE_VARIABLE_USERNAME" > .provision-env
echo "export PROVISION_EMAIL=${CI_PIPELINE_VARIABLE_EMAIL}" >> .provision-env echo "export PROVISION_EMAIL=$CI_PIPELINE_VARIABLE_EMAIL" >> .provision-env
- name: prepare - name: prepare
image: alpine image: alpine
@ -187,7 +187,7 @@ steps:
commands: commands:
- | - |
curl -s -X POST -H 'Content-type: application/json' \ curl -s -X POST -H 'Content-type: application/json' \
--data "{\"channel\":\"general\",\"text\":\"Woodpecker CI: User provisioning for ${CI_PIPELINE_VARIABLE_USERNAME:-unknown} ${CI_PIPELINE_STATUS}\"}" \ --data "{\"channel\":\"general\",\"text\":\"Woodpecker CI: User provisioning $CI_PIPELINE_STATUS\"}" \
"$SLACK_WEBHOOK" || true "$SLACK_WEBHOOK" || true
environment: environment:
SLACK_WEBHOOK: SLACK_WEBHOOK: