How can you know if a test failed or succeeded in Post-test commands?

deployment
circle.yml

#1

Hi there,

I am trying to add a deploy functionality on circle-ci for our test servers.

I would like to execute my deploy-branch-on-test.sh after the tests are run. However right now they also execute when the test fails.

How could I prevent it from being deployed when the test fails ?

I cannot use the deploy command in the circle.yml file as the branches we use change all the time and would be quite cumbersome to update on every branch…

Cheers

deploy-branch-on-test.sh

#!/bin/sh

BRANCH_TO_DEPLOY=$1
TEST_INSTANCE=$2

if  [ -z ${BRANCH_TO_DEPLOY} ]; then
  echo "Please specifiy a branch to deploy."
  echo
  echo "e.g. ./scripts/deploy-branch-on-test.sh sprint-39/battle test"
  echo
  exit
fi

if  [ -z ${TEST_INSTANCE} ]; then
  echo "Please specifiy on which test instance you want to deploy your branch."
  echo
  echo "e.g. ./scripts/deploy-branch-on-test.sh sprint-39/battle test"
  echo
  exit
fi

if [ "${CIRCLE_BRANCH}" == "${BRANCH_TO_DEPLOY}" ]; then
  ssh $TEST_INSTANCE "cd server && git checkout ${BRANCH_TO_DEPLOY} && git pull && docker restart web && ./node_modules/.bin/webpack"
fi

#2

I ended up using workflows, which guaranteed the test success before deploy.


#3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.