Fabric

Report deploys to Rollbar from Fabric

Here's an example Fabric command. Call this from your deploy command when a deploy has completed successfully.

import requests
def rollbar_record_deploy():
    access_token = 'POST_SERVER_ITEM_ACCESS_TOKEN'
    environment = 'production'
    local_username = local('whoami', capture=True)
    # fetch last committed revision in the locally-checked out branch
    revision = local('git log -n 1 --pretty=format:"%H"', capture=True)

    resp = requests.post('https://api.rollbar.com/api/1/deploy/', {
        'access_token': access_token,
        'environment': environment,
        'local_username': local_username,
        'revision': revision
    }, timeout=3)

    if resp.status_code == 200:
        print("Deploy recorded successfully.")
    else:
        print("Error recording deploy:", resp.text)

For details of the /deploy/ endpoint, see Report a deploy.


Did this page help you?