• Print
  • Share
  • Dark
    Light

CircleCI

  • Updated on 07 Jun 2018
  • 1 minute to read
  • Contributors

If you are using CircleCI for your CI/CD pipeline, you can install the Stackify Retrace Deployment Recorder plugin to help you notify Retrace's Deployments API during or after your deployments. The Deployment Recorder offers three different actions (Start, Complete, and Cancel) that can be passed as arguments depending on how you are configuring the Task within your existing pipeline.

Check out our Deployment Tracking Overview guide to learn how these deployment notifications can be used within Retrace.

Using the CircleCI config.yml file you can make a call to a shell script file that uses curl to post to Retrace's Deployment Recorder. Below is the script that can be used as well as some suggestions of CircleCI environment variables that you can pass in for additional functionality and re-usability.  

CircleCI Bash Script

echo "Stackify Retrace Deployment Recording Started"
APPNAME=$1
VERSION=$2
ENVIRONMENT=$3
NAME=$4
URI=$5
BRANCH=$6
COMMIT=$7

PARAMETERS='{"AppName":"'$APPNAME'", "Version":"'$VERSION'", "EnvironmentName":"'$ENVIRONMENT'", "Name":"'$NAME'", "Uri":"'$URI'", "Branch":"'$BRANCH'", "Commit":"'$COMMIT'"}'
echo "$PARAMETERS"

curl -i -X POST 
https://api.stackify.net/api/v1/deployments/complete 
-H 'authorization: ApiKey ENTER_YOUR_API_KEY' 
-H 'content-type: application/json' 
-d "$PARAMETERS"
echo "Stackify Retrace Deployment Recording Finished"

Note: You will need to replace the placeholder text  with your Retrace Account Activation Key aka your Api Key which is located under Settings > Account within Retrace.

CircleCI YAML step configuration

Keep in mind when using the config.yml file that you will have to specify the checkout step before you are able to access any files within your repo.  In this example, we have named the above script stackify_deploy.sh and committed it to the .scripts folder within our GitHub repo.

deploy:
  docker:
    - image: circleci/openjdk:8-jdk
  steps:
    - checkout
    - run: bash ./.scripts/stackify_deploy.sh AppName $CIRCLE_BUILD_NUM EnvironmentName $CIRCLE_PROJECT_REPONAME $CIRCLE_BUILD_URL $CIRCLE_BRANCH $CIRCLE_SHA1

Note: Only the first 3 arguments are required AppName, Version, and Environment. Also using the CircleCI Environment variables is completely optional and can be replaced with any variables or arguments of your choosing.