Last active
August 29, 2015 14:03
-
-
Save dk8996/6a4091b432e38dde223a to your computer and use it in GitHub Desktop.
Codeship and Stackdriver integration. Send deploy events to Stackdriver.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export DEPLOY_ENV=dev | |
pip install requests | |
python ~/src/github.com/<your-path>/deploy-event.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Author: Dimitry Kudryavtsev | |
import requests | |
import json | |
import os | |
def submit_code_deploy_event(): | |
""" Submit a code deploy event to Stackdriver """ | |
headers = { 'content-type': 'application/json', | |
'x-stackdriver-apikey': '<YOURAPIKEY>' } | |
deploy_event = { 'revision_id': os.environ.get('CI_COMMIT_ID'), | |
'deployed_by': os.environ.get('CI_COMMITTER_NAME'), | |
'deployed_to': os.environ.get('DEPLOY_ENV'), | |
'repository': os.environ.get('CI_BRANCH')} | |
resp = requests.post( 'https://event-gateway.stackdriver.com/v1/deployevent', | |
data=json.dumps(deploy_event), | |
headers=headers) | |
assert resp.ok, 'Failed to submit code deploy event.' | |
if __name__ == '__main__': | |
submit_code_deploy_event() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For instructions on how to do this please see this blog post:
http://www.mentful.com/2014/06/27/connecting-codeship-to-stackdriver/