#!/bin/bash # Copyright 2019 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This script build node problem detector for presubmit and CI jobs and push to # staging, so that kubernetes E2E tests have access to the build. set -o errexit set -o nounset set -o pipefail 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"} 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." } function get-version() { if [ -d .git ]; then echo `git describe --tags --dirty` else echo "UNKNOWN" fi } function install-lib() { apt-get update apt-get install -y libsystemd-dev } function write-env-file() { local -r env_file="${1}" if [[ -z "${env_file}" ]]; then echo "ERROR: env_file is missing." exit 1 fi cat > ${ROOT_PATH}/${env_file} <