Jenkinsfile: tolerate unregistered parameters on a job's first run

A new job's first run has no PORTAL_REQUEST_ID/PORTAL_USER/CHANGELOG yet,
which tripped set -u in Preflight. Default them to empty everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nicholas Andrew 2026-10-11 00:52:02 -04:00
commit 6cebf1a5a6

6
Jenkinsfile vendored
View file

@ -134,7 +134,7 @@ pipeline {
set -Eeuo pipefail
[[ "$DEVICE" =~ ^[A-Za-z0-9_]+$ ]] || { echo "ERROR: bad DEVICE '$DEVICE'"; exit 1; }
[[ -z "$PORTAL_REQUEST_ID" || "$PORTAL_REQUEST_ID" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]] \
[[ -z "${PORTAL_REQUEST_ID:-}" || "${PORTAL_REQUEST_ID:-}" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]] \
|| { echo "ERROR: bad PORTAL_REQUEST_ID"; exit 1; }
if [ -z "$TEST_JOB" ] && [ "$MANIFEST_REF" != "$MANIFEST_BRANCH" ]; then
echo "ERROR: MANIFEST_REF is only allowed on cms- test jobs"
@ -838,7 +838,7 @@ PYEOF
--arg tree_commit "$TREE_COMMIT" \
--arg tree_subject "$TREE_SUBJECT" \
--arg operator_changelog "${CHANGELOG:-$CHANGELOG_DEFAULT}" \
--arg portal_request_id "$PORTAL_REQUEST_ID" \
--arg portal_request_id "${PORTAL_REQUEST_ID:-}" \
'{
project: $project,
project_name: $project_name,
@ -897,7 +897,7 @@ PYEOF
exit 1
fi
if [ -n "$PORTAL_REQUEST_ID" ] && ! jq -e '.started_by' "$RESPONSE_FILE" >/dev/null 2>&1; then
if [ -n "${PORTAL_REQUEST_ID:-}" ] && ! jq -e '.started_by' "$RESPONSE_FILE" >/dev/null 2>&1; then
echo "WARNING: portal did not attribute this build: $(jq -r '.attribution_warning // empty' "$RESPONSE_FILE")"
fi