diff --git a/test/build.sh b/test/build.sh index 2e608598..8cab8509 100755 --- a/test/build.sh +++ b/test/build.sh @@ -26,15 +26,33 @@ NPD_STAGING_PATH=${NPD_STAGING_PATH:-"gs://node-problem-detector-staging"} NPD_STAGING_REGISTRY=${NPD_STAGING_REGISTRY:-"gcr.io/node-problem-detector-staging"} PR_ENV_FILENAME=${PR_ENV_FILENAME:-"pr.env"} CI_ENV_FILENAME=${CI_ENV_FILENAME:-"ci.env"} +CI_CUSTOM_FLAGS_ENV_FILENAME=${CI_CUSTOM_FLAGS_ENV_FILENAME:-"ci-custom-flags.env"} ROOT_PATH=$(git rev-parse --show-toplevel) GCS_URL_PREFIX="https://storage.googleapis.com/" + function print-help() { - echo "Usage: build.sh [args...]" - echo "Available arguments:" - echo " pr [pull_number]: Build node-problem-detector for presubmit jobs and push to staging." - echo " ci: Build node-problem-detector for CI jobs and push to staging." - echo " get-ci-env: Download environment variable file from staging for CI job." + echo "Usage: build.sh [flags] [command]" + echo + echo "Available flags:" + echo " -p [PR_NUMBER] Specify the pull request number when building for a presubmit job." + echo " -f Use custom flags." + echo + echo "Available commands:" + echo " help Print this help message" + echo " pr Build node-problem-detector for presubmit jobs and push to staging. Flag -p is required." + echo " ci Build node-problem-detector for CI jobs and push to staging." + echo " get-ci-env Download environment variable file from staging for CI job." + echo " install-lib Install the libraries needed." + echo + echo "Examples:" + echo " build.sh help" + echo " build.sh -p [PR_NUMBER] pr" + echo " build.sh -p [PR_NUMBER] -f pr" + echo " build.sh ci" + echo " build.sh get-ci-env" + echo " build.sh -f get-ci-env" + echo " build.sh install-lib" } function get-version() { @@ -65,17 +83,43 @@ export NODE_PROBLEM_DETECTOR_TAR_HASH=$(sha1sum ${ROOT_PATH}/node-problem-detect export EXTRA_ENVS=NODE_PROBLEM_DETECTOR_IMAGE=${REGISTRY}/node-problem-detector:${TAG} EOF + if [[ -n "${NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS:-}" ]]; then + cat >> ${ROOT_PATH}/${env_file} <