From dcceea9dbb18712565e7380074ba3a6790f79b9e Mon Sep 17 00:00:00 2001 From: Hosung Song Date: Fri, 20 Apr 2018 12:42:26 -0700 Subject: [PATCH] Update .travis.yml for minor things --- .travis.yml | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8d6e946..4e863e0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ dist: trusty sudo: off +branches: + only: + - master + language: node_js # Base language is Nodejs (used for liniting and basic validation). addons: @@ -24,32 +28,38 @@ cache: script: # Run the lint tests, then if env vars are present validate the template then try building the stack. - npm test - if [ "$SPNAME" != "" -a "$SPPASSWORD" != "" -a "$SPTENANT" != "" -a "$SPSSHKEY" != "" ]; then - export RUNBUILD="true"; + export RUNBUILD="true" + export AZMDLGROUP="azmdl-travis-$TRAVIS_BUILD_NUMBER" fi - - if [ "$LOCATION" == "" ]; then - export LOCATION="westus"; + - if [ -z "$LOCATION" ]; then + export LOCATION="westus" fi - - if [ "$RUNBUILD" == "true" ]; then - echo "Running Azure setup steps."; - az login --service-principal -u "$SPNAME" -p "$SPPASSWORD" --tenant "$SPTENANT"; - az group create -l "$LOCATION" -g "moodle-azure-$TRAVIS_BUILD_NUMBER"; + - if [ "$RUNBUILD" = "true" ]; then + echo "Running Azure setup steps." + az login --service-principal -u "$SPNAME" -p "$SPPASSWORD" --tenant "$SPTENANT" + az group create -l "$LOCATION" -g "$AZMDLGROUP" else - echo "Skipping Azure setup."; + echo "Skipping Azure setup." fi - - if [ "$RUNBUILD" == "true" ]; then - echo "Running Azure validation step."; - az group deployment validate --resource-group "moodle-azure-$TRAVIS_BUILD_NUMBER" --template-file azuredeploy.json --parameters azuredeploy.parameters.json --parameters sshPublicKey="$SPSSHKEY"; + - if [ "$RUNBUILD" = "true" ]; then + echo "Running Azure validation step." + VALIDATION_RESULT=$(az group deployment validate --resource-group "$AZMDLGROUP" --template-file azuredeploy.json --parameters azuredeploy.parameters.json --parameters sshPublicKey="$SPSSHKEY") + if [ -n "$VALIDATION_RESULT" ]; then + echo "Azure template validation failed! Error message:" + echo $VALIDATION_RESULT + exit 1 + fi else - echo "Skipping Azure validation."; + echo "Skipping Azure validation." fi - - if [ "$RUNBUILD" == "true" ]; then - echo "Running Azure build step."; - az group deployment create --resource-group "moodle-azure-$TRAVIS_BUILD_NUMBER" --template-file azuredeploy.json --parameters azuredeploy.parameters.json --parameters sshPublicKey="$SPSSHKEY" --debug --verbose; + - if [ "$RUNBUILD" = "true" ]; then + echo "Running Azure build step." + az group deployment create --resource-group "$AZMDLGROUP" --template-file azuredeploy.json --parameters azuredeploy.parameters.json --parameters sshPublicKey="$SPSSHKEY" --debug --verbose else - echo "Skipping Azure build."; + echo "Skipping Azure build." fi after_script: # Teardown group and created resource after build. - - if [ "$RUNBUILD" == "true" ]; then - az group delete -g "moodle-azure-$TRAVIS_BUILD_NUMBER" -y; + - if [ "$RUNBUILD" = "true" ]; then + az group delete -g "moodle-azure-$TRAVIS_BUILD_NUMBER" -y --no-wait fi