Skip to content

Commit

Permalink
Add support for BUILD_NUMBER (temporarily)
Browse files Browse the repository at this point in the history
Some old scripts still use BUILD_NUMBER instead of the
newer BUILD_ID. The later is the preferred one in new
scripts (no matter both still work).

Once moodlehq/moodle-local_ci#303 is fixed
we'll revert this change, when we have everything working with BUILD_ID.
  • Loading branch information
stronk7 committed Jun 7, 2024
1 parent 289f9d1 commit 25c739b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runner/main/modules/env/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function env_env() {
# Environment module checks.
function env_check() {
# These env variables must be set for the module to work.
verify_env JOBTYPE SHAREDDIR
verify_env JOBTYPE SHAREDDIR BUILD_ID
}

# Environment module config.
Expand All @@ -44,6 +44,13 @@ function env_setup() {
rm -f "${ENVIROPATH}"
touch "${ENVIROPATH}"

# Always add the BUILD_ID, in case it's needed by any of the scripts out from the runner.
echo "BUILD_ID=${BUILD_ID}" >> "${ENVIROPATH}"

# TODO: Remove this once https://github.com/moodlehq/moodle-local_ci/issues/303 is fixed.
# Always make BUILD_NUMBER available, some old scripts use it.
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> "${ENVIROPATH}"

# Add all the variables that the job type requires.
for var in $(get_job_to_env_file "${JOBTYPE}"); do
# Docker does not support multiline env variables via --env-file, so we need to
Expand Down
4 changes: 4 additions & 0 deletions runner/main/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ fi
# BUILD_ID, if not defined use the current PID.
BUILD_ID="${BUILD_ID:-$$}"

# TODO: Remove this once https://github.com/moodlehq/moodle-local_ci/issues/303 is fixed.
# Always make BUILD_NUMBER available, some old scripts use it.
BUILD_NUMBER="${BUILD_ID}"

# Base directory to be shared with some containers that will read/write information there (timing, environment, logs... etc.).
SHAREDDIR="${WORKSPACE}"/"${BUILD_ID}"

Expand Down

0 comments on commit 25c739b

Please sign in to comment.