From 5b1c42292228992bd504aa3cf00347dc67aee3cb Mon Sep 17 00:00:00 2001 From: matthew wagoner Date: Thu, 30 Nov 2017 07:00:04 -0500 Subject: [PATCH] Update CI Add files and bluemix auth to bring repository up to date with current CI for our org --- .travis.yml | 6 ++++-- scripts/bx_auth.sh | 24 ++++++++++++++++++++++++ scripts/install.sh | 7 ++----- scripts/resources.sh | 20 ++++++++++++++++++++ 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 scripts/bx_auth.sh create mode 100644 scripts/resources.sh diff --git a/.travis.yml b/.travis.yml index 45d2aa4..006df4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,10 @@ +--- language: bash script: true sudo: required -before_install: -- bash scripts/install.sh +install: + - "./scripts/install.sh" + - "./scripts/bx_auth.sh" group: stable dist: precise os: linux diff --git a/scripts/bx_auth.sh b/scripts/bx_auth.sh new file mode 100644 index 0000000..2d6a955 --- /dev/null +++ b/scripts/bx_auth.sh @@ -0,0 +1,24 @@ +#!/bin/bash -e + +# This script is intended to be run by Travis CI. If running elsewhere, invoke +# it with: TRAVIS_PULL_REQUEST=false [path to script] +# If no credentials are provided at runtime, bx will use the environment +# variable BLUEMIX_API_KEY. If no API key is set, it will prompt for +# credentials. + +# shellcheck disable=SC1090 +source "$(dirname "$0")"/../scripts/resources.sh + +BLUEMIX_ORG="Developer Advocacy" +BLUEMIX_SPACE="dev" + +is_pull_request "$0" + +echo "Authenticating to Bluemix" +bx login -a https://api.ng.bluemix.net + +echo "Targeting Bluemix org and space" +bx target -o "$BLUEMIX_ORG" -s "$BLUEMIX_SPACE" + +echo "Initializing Bluemix Container Service" +bx cs init diff --git a/scripts/install.sh b/scripts/install.sh index 1abf6f9..cad9ef2 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -12,10 +12,7 @@ tar -xvf Bluemix_CLI.tar.gz sudo ./Bluemix_CLI/install_bluemix_cli } -function bluemix_auth() { -echo "Authenticating with Bluemix" -echo "1" | bx login -a https://api.ng.bluemix.net --apikey $BLUEMIX_AUTH -curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl +function install_kubectl() { bx plugin install container-service -r Bluemix echo "Installing kubectl" chmod +x ./kubectl @@ -186,7 +183,7 @@ done install_bluemix_cli -bluemix_auth +install_kubectl cluster_setup initial_setup create_platform_services diff --git a/scripts/resources.sh b/scripts/resources.sh new file mode 100644 index 0000000..e0c1f0b --- /dev/null +++ b/scripts/resources.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# This script contains functions used by many of the scripts found in scripts/ +# and tests/. + +test_failed(){ + echo -e >&2 "\033[0;31m$1 test failed!\033[0m" + exit 1 +} + +test_passed(){ + echo -e "\033[0;32m$1 test passed!\033[0m" +} + +is_pull_request(){ + if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then + echo -e "\033[0;33mPull Request detected; not running $1!\033[0m" + exit 0 + fi +}