@@ -27,13 +27,14 @@ NPD_STAGING_REGISTRY=${NPD_STAGING_REGISTRY:-"gcr.io/node-problem-detector-stagi
27
27
PR_ENV_FILENAME=${PR_ENV_FILENAME:- " pr.env" }
28
28
CI_ENV_FILENAME=${CI_ENV_FILENAME:- " ci.env" }
29
29
ROOT_PATH=$( git rev-parse --show-toplevel)
30
+ GCS_URL_PREFIX=" https://storage.googleapis.com/"
30
31
31
32
function print-help() {
32
33
echo " Usage: build.sh [args...]"
33
34
echo " Available arguments:"
34
- echo " pr [pull_refs ]: Build node-problem-detector for presubmit jobs and push to staging."
35
- echo " ci: Build node-problem-detector for CI jobs and push to staging."
36
- echo " get-ci-env: Download environment variable file from staging for CI job."
35
+ echo " pr [pull_number ]: Build node-problem-detector for presubmit jobs and push to staging."
36
+ echo " ci: Build node-problem-detector for CI jobs and push to staging."
37
+ echo " get-ci-env: Download environment variable file from staging for CI job."
37
38
}
38
39
39
40
function get-version() {
@@ -44,6 +45,11 @@ function get-version() {
44
45
fi
45
46
}
46
47
48
+ function install-lib() {
49
+ apt-get update
50
+ apt-get install -y libsystemd-dev
51
+ }
52
+
47
53
function write-env-file() {
48
54
local -r env_file=" ${1} "
49
55
if [[ -z " ${env_file} " ]]; then
@@ -52,20 +58,29 @@ function write-env-file() {
52
58
fi
53
59
54
60
cat > ${ROOT_PATH} /${env_file} << EOF
55
- export EXTRA_ENVS=NODE_PROBLEM_DETECTOR_IMAGE= ${REGISTRY} /node-problem-detector: ${TAG}
56
- export NODE_PROBLEM_DETECTOR_RELEASE_PATH=${UPLOAD_PATH}
61
+ export KUBE_ENABLE_NODE_PROBLEM_DETECTOR=standalone
62
+ export NODE_PROBLEM_DETECTOR_RELEASE_PATH=${UPLOAD_PATH/ gs : \/\/ / ${GCS_URL_PREFIX} }
57
63
export NODE_PROBLEM_DETECTOR_VERSION=${VERSION}
58
64
export NODE_PROBLEM_DETECTOR_TAR_HASH=$( sha1sum ${ROOT_PATH} /node-problem-detector-${VERSION} .tar.gz | cut -d ' ' -f1)
65
+ export EXTRA_ENVS=NODE_PROBLEM_DETECTOR_IMAGE=${REGISTRY} /node-problem-detector:${TAG}
59
66
EOF
67
+
68
+ set -x
69
+ cat ${ROOT_PATH} /${env_file}
70
+ set +x
60
71
}
61
72
62
73
function build-pr() {
63
- local -r PR =" ${1} "
64
- if [[ -z " ${PR } " ]]; then
65
- echo " ERROR: pull_refs is missing."
74
+ local -r PR_NUMBER =" ${1} "
75
+ if [[ -z " ${PR_NUMBER } " ]]; then
76
+ echo " ERROR: pull_number is missing."
66
77
print-help
67
78
exit 1
68
79
fi
80
+ # Use the PR number and current time as the name, e.g., pr261-20190314.224907.862195792
81
+ local -r PR=" pr${PR_NUMBER} -$( date +%Y%m%d.%H%M%S.%N) "
82
+ echo " Building for PR ${PR} ..."
83
+ install-lib
69
84
70
85
export UPLOAD_PATH=" ${NPD_STAGING_PATH} /pr/${PR} "
71
86
export REGISTRY=" ${NPD_STAGING_REGISTRY} /pr/${PR} "
@@ -76,6 +91,7 @@ function build-pr() {
76
91
}
77
92
78
93
function build-ci() {
94
+ install-lib
79
95
export UPLOAD_PATH=" ${NPD_STAGING_PATH} /ci"
80
96
export REGISTRY=" ${NPD_STAGING_REGISTRY} /ci"
81
97
export VERSION=$( get-version)
@@ -101,7 +117,7 @@ COMMAND="${1}"
101
117
102
118
if [[ " ${COMMAND} " == " pr" ]]; then
103
119
if [[ " $# " -ne 2 ]]; then
104
- echo " ERROR: pull_refs is missing."
120
+ echo " ERROR: pull_number is missing."
105
121
print-help
106
122
exit 1
107
123
fi
@@ -110,9 +126,10 @@ elif [[ "${COMMAND}" == "ci" ]]; then
110
126
build-ci
111
127
elif [[ " ${COMMAND} " == " get-ci-env" ]]; then
112
128
get-ci-env
129
+ elif [[ " ${COMMAND} " == " install-lib" ]]; then
130
+ install-lib
113
131
else
114
132
echo " ERROR: Invalid command."
115
133
print-help
116
134
exit 1
117
135
fi
118
-
0 commit comments