Skip to content

Instantly share code, notes, and snippets.

@datacoda
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datacoda/f32ec0a21a04718ff36f to your computer and use it in GitHub Desktop.
Save datacoda/f32ec0a21a04718ff36f to your computer and use it in GitHub Desktop.
Shippable and HipChat notifications
language: ruby
bundler_args: --without kitchen_vagrant
cache: true
env:
- secure: {{ENCRYPTED_ENVIRONMENT_VARS_FROM_UI}}
rvm:
- 2.0.0
script:
- bundle exec rake ci
notifications:
email: false
before_install:
- export SHORT=`echo $COMMIT | cut -c 1-7`
- export HC_MESSAGE="<a href=\"${BUILD_URL}\">Started a new build</a> for branch ${BRANCH} on ${REPO_NAME} (${SHORT})"
- export HC_CONFIG="room_id=${HIPCHAT_ROOM}&from=Shippable&message_format=html&notify=1&color=yellow"
- export HC_NOTIFY_API="https://api.hipchat.com/v1/rooms/message?auth_token=${HIPCHAT_TOKEN}"
- curl -d $HC_CONFIG --data-urlencode "message=${HC_MESSAGE}" ${HC_NOTIFY_API}
after_success:
- export SHORT=`echo $COMMIT | cut -c 1-7`
- export HC_STATUS="succeeded"
- export HC_MESSAGE="<a href=\"${BUILD_URL}\">Build ${HC_STATUS}</a> for branch ${BRANCH} on ${REPO_NAME} (${SHORT})"
- export HC_CONFIG="room_id=${HIPCHAT_ROOM}&from=Shippable&message_format=html&notify=1&color=green"
- export HC_NOTIFY_API="https://api.hipchat.com/v1/rooms/message?auth_token=${HIPCHAT_TOKEN}"
- curl -d $HC_CONFIG --data-urlencode "message=${HC_MESSAGE}" ${HC_NOTIFY_API}
after_failure:
- export SHORT=`echo $COMMIT | cut -c 1-7`
- export HC_STATUS="failed"
- export HC_MESSAGE="<a href=\"${BUILD_URL}\">Build ${HC_STATUS}</a> for branch ${BRANCH} on ${REPO_NAME} (${SHORT})"
- export HC_CONFIG="room_id=${HIPCHAT_ROOM}&from=Shippable&message_format=html&notify=1&color=red"
- export HC_NOTIFY_API="https://api.hipchat.com/v1/rooms/message?auth_token=${HIPCHAT_TOKEN}"
- curl -d $HC_CONFIG --data-urlencode "message=${HC_MESSAGE}" ${HC_NOTIFY_API}
@datacoda
Copy link
Author

HIPCHAT_TOKEN and HIPCHAT_ROOM are the environment variables that need to be encrypted from the dashboard UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment