Welcome, Guest Login

Support Center

Sending Code Deploy Events to Stackdriver

Last Updated: Mar 24, 2014 09:02PM EDT

Stackdriver supports ingesting and displaying code deploy events. To send these events, you can do the following:

  1. Create a new API key in your Stackdriver Account Settings
  2. Submit a Code Deploy Event with the API key

(Code snippets in this section are written in Python.)

To push a code deploy event to Stackdriver, you will POST a message to the event gateway and include the API key in the HTTP header.

Example Code Deploy Data:

Each code deploy has the following fields:

  • revision_id - The revision of the code that was deployed.
  • (Optional) deployed_by - The person or robot responsible for deploying the code.
  • (Optional) deployed_to - The environment code was deployed to. (ie: development, staging, production)
  • (Optional) repository - The repository (or project) deployed.
deploy_event = { 'revision_id': '87230611cdc7e5ff7723a91e715367c553ad1115',
                 'deployed_by': 'JoeyI',
                 'deployed_to': 'production',
                 'repository':  'prototype_dashboard' }

Example Code Deploy POST:

A complete working example of posting a deploy event:

import requests
import json

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': '87230611cdc7e5ff7723a91e715367c553ad1115',
                     'deployed_by': 'JoeyI',
                     'deployed_to': 'production',
                     'repository':  'prototype_dashboard' }

    resp = requests.post( 'https://event-gateway.stackdriver.com/v1/deployevent',

    assert resp.ok, 'Failed to submit code deploy event.'

if __name__ == '__main__':

seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found