Auto-derive MIGRATE_PIPELINE_ROOT in new_docker_build.sh
Resolution order (highest precedence first): 1. exported MIGRATE_PIPELINE_ROOT (e.g. from a Jenkinsfile) 2. MIGRATE_PIPELINE_ROOT set by .envrc in this directory 3. derived from the script location (three levels up) The script always lives at <root>/qt-migration-legatus/qt6-after/ qt6-migrated-legatus, so the pipeline root is three levels up. This makes the script work in a fresh Jenkins checkout with no environment setup at all, and .envrc is no longer required.
This commit is contained in:
1 parent
52df1c8ae9
commit
1dd1e86355
1 file changed
+28
-10
@@ -8,8 +8,8 @@ set -euo pipefail
|
|||||||
# Lts/Proxies/TrainingAreaBase) inside the prebuilt Docker image and
|
# Lts/Proxies/TrainingAreaBase) inside the prebuilt Docker image and
|
||||||
# optionally runs the Jenkins builder to produce the release DEB packages.
|
# optionally runs the Jenkins builder to produce the release DEB packages.
|
||||||
#
|
#
|
||||||
# - Loads environment from .envrc
|
# - Resolves MIGRATE_PIPELINE_ROOT (exported variable, .envrc, or derived
|
||||||
# - Validates MIGRATE_PIPELINE_ROOT and rti_license.dat
|
# from the script location) and validates rti_license.dat
|
||||||
# - Uses a prebuilt Docker image with all build dependencies installed
|
# - Uses a prebuilt Docker image with all build dependencies installed
|
||||||
# (build it from ./Dockerfile via --build-prebuilt-image)
|
# (build it from ./Dockerfile via --build-prebuilt-image)
|
||||||
# - Optional deletion of the prebuilt Docker image via --delete-prebuilt-image
|
# - Optional deletion of the prebuilt Docker image via --delete-prebuilt-image
|
||||||
@@ -55,8 +55,10 @@ Environment variable overrides:
|
|||||||
BUILD_NUMBER=<num>
|
BUILD_NUMBER=<num>
|
||||||
BUILD_TAG=<tag>
|
BUILD_TAG=<tag>
|
||||||
|
|
||||||
Required .envrc variable:
|
MIGRATE_PIPELINE_ROOT resolution (highest precedence first):
|
||||||
MIGRATE_PIPELINE_ROOT=<absolute-path>
|
1. exported MIGRATE_PIPELINE_ROOT (e.g. from a Jenkinsfile)
|
||||||
|
2. MIGRATE_PIPELINE_ROOT set by .envrc in this directory
|
||||||
|
3. derived from the script location (three levels up)
|
||||||
|
|
||||||
Expected file:
|
Expected file:
|
||||||
${MIGRATE_PIPELINE_ROOT}/rti_license.dat
|
${MIGRATE_PIPELINE_ROOT}/rti_license.dat
|
||||||
@@ -259,14 +261,30 @@ build_prebuilt_image() {
|
|||||||
|
|
||||||
require_command docker
|
require_command docker
|
||||||
|
|
||||||
if [[ ! -f ".envrc" ]]; then
|
# MIGRATE_PIPELINE_ROOT resolution (highest precedence first):
|
||||||
die ".envrc not found in current directory. Please create .envrc with required environment variables (e.g., MIGRATE_PIPELINE_ROOT)"
|
# 1. exported environment variable (e.g. from a Jenkinsfile)
|
||||||
|
# 2. .envrc in this directory (if present)
|
||||||
|
# 3. derived from this script's location - the script always lives at
|
||||||
|
# <root>/qt-migration-legatus/qt6-after/qt6-migrated-legatus, so the
|
||||||
|
# pipeline root is three levels up. This makes the script work in a
|
||||||
|
# fresh Jenkins checkout with no environment setup at all.
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
MIGRATE_PIPELINE_ROOT_DEFAULT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
|
||||||
|
PIPELINE_ROOT_EXPORTED="${MIGRATE_PIPELINE_ROOT:-}"
|
||||||
|
|
||||||
|
if [[ -f ".envrc" ]]; then
|
||||||
|
set -a
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source ".envrc"
|
||||||
|
set +a
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -a
|
# An explicitly exported MIGRATE_PIPELINE_ROOT (Jenkinsfile) wins over .envrc
|
||||||
# shellcheck disable=SC1091
|
if [[ -n "${PIPELINE_ROOT_EXPORTED}" ]]; then
|
||||||
source ".envrc"
|
MIGRATE_PIPELINE_ROOT="${PIPELINE_ROOT_EXPORTED}"
|
||||||
set +a
|
else
|
||||||
|
MIGRATE_PIPELINE_ROOT="${MIGRATE_PIPELINE_ROOT:-${MIGRATE_PIPELINE_ROOT_DEFAULT}}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Fixed configuration for the release validation-scope branch
|
# Fixed configuration for the release validation-scope branch
|
||||||
RELEASE_BUILD=ON
|
RELEASE_BUILD=ON
|
||||||
|
|||||||
Reference in new issue
Block a user