From 02dbdfce985f96ad98a04a18d83b263d482fb3c2 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Mon, 25 Apr 2016 15:10:15 -0700 Subject: [PATCH] Allow Travis to continue build if decryption fails. (#187) Decryption of the service key can fail if Travis is building from a fork instead of a branch. --- .travis.yml | 12 ++++++++---- travis.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100755 travis.sh diff --git a/.travis.yml b/.travis.yml index 1f24d1d1a51..a4c5bcc8eee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,16 @@ language: java jdk: - oraclejdk8 -env: - - GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/service-account.json GCLOUD_PROJECT=cloud-samples-tests before_install: - openssl aes-256-cbc -K $encrypted_37a4f399de75_key -iv $encrypted_37a4f399de75_iv -in service-account.json.enc -out service-account.json -d - -script: mvn --batch-mode clean verify -DskipTests=false | egrep -v "(^\[INFO\] Download|^\[INFO\].*skipping)" + && export GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/service-account.json GCLOUD_PROJECT=cloud-samples-tests + || true +# Skip the install step, since Maven will download the dependencies we need +# when the test build runs. +# http://stackoverflow.com/q/31945809/101923 +# https://docs.travis-ci.com/user/customizing-the-build/#Skipping-the-Installation-Step +install: true +script: ./travis.sh after_success: - mvn clean cobertura:cobertura coveralls:report branches: diff --git a/travis.sh b/travis.sh new file mode 100755 index 00000000000..fe0b680e9d9 --- /dev/null +++ b/travis.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Copyright 2016 Google Inc. All Rights Reserved. +# +# 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. + +set -e +set -x +# Set pipefail so that `egrep` does not eat the exit code. +set -o pipefail + +SKIP_TESTS=false +if [ -z "$GOOGLE_APPLICATION_CREDENTIALS"]; then + SKIP_TESTS=true +fi +mvn --batch-mode clean verify -DskipTests=$SKIP_TESTS | egrep -v "(^\[INFO\] Download|^\[INFO\].*skipping)" +