From a39561df5f024789d3e6fc4677e4b4502d0015b7 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 27 Feb 2017 20:21:21 +0100 Subject: [PATCH] Setup the secrets only for non-pull-request builds when we have the secure environment variables --- .travis.yml | 11 +---------- .travis/setup-secrets.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .travis/setup-secrets.sh diff --git a/.travis.yml b/.travis.yml index 28092ba074..668503761d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,19 +8,10 @@ addons: language: java jdk: oraclejdk8 before_install: + - bash .travis/setup-secrets.sh - bash .travis/install-configure-maven.sh - export M2_HOME=$HOME/apache-maven-3.3.9 - export PATH=$HOME/apache-maven-3.3.9/bin:${PATH} - - openssl aes-256-cbc -K $encrypted_5630fbebf057_key -iv $encrypted_5630fbebf057_iv -in .travis/secrets.tar.enc -out .travis/secrets.tar -d - - pushd .travis && tar xfv secrets.tar && popd - - mkdir -p "$HOME/.ssh" - - chmod 700 "$HOME/.ssh" - - mv .travis/id_rsa "$HOME/.ssh/id_rsa" - - chmod 600 "$HOME/.ssh/id_rsa" - - mkdir -p "$HOME/.gpg" - - gpg --batch --import .travis/release-signing-key-82DE7BE82166E84E.gpg - - rm .travis/secrets.tar - - rm .travis/release-signing-key-82DE7BE82166E84E.gpg install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V before_script: true script: diff --git a/.travis/setup-secrets.sh b/.travis/setup-secrets.sh new file mode 100644 index 0000000000..c1daea69bf --- /dev/null +++ b/.travis/setup-secrets.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -ev + +if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "${TRAVIS_SECURE_ENV_VARS}" != "true" ]; then + echo "Not setting up secrets (TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} TRAVIS_SECURE_ENV_VARS=${TRAVIS_SECURE_ENV_VARS})." + exit 0 +fi + + +openssl aes-256-cbc -K $encrypted_5630fbebf057_key -iv $encrypted_5630fbebf057_iv -in .travis/secrets.tar.enc -out .travis/secrets.tar -d +pushd .travis && tar xfv secrets.tar && popd +mkdir -p "$HOME/.ssh" +chmod 700 "$HOME/.ssh" +mv .travis/id_rsa "$HOME/.ssh/id_rsa" +chmod 600 "$HOME/.ssh/id_rsa" +mkdir -p "$HOME/.gpg" +gpg --batch --import .travis/release-signing-key-82DE7BE82166E84E.gpg +rm .travis/secrets.tar +rm .travis/release-signing-key-82DE7BE82166E84E.gpg