In Compass, there are two main methods for getting events from tools to show on a component’s activity feed. One method is by connecting event sources from the component’s details page in Compass and the other is by sending events using the Compass REST API.
To send events using the REST API:
Here, we’ll use a cURL command as an example to show you how to call the REST API. You can either use the cURL command we’ve shown here or call the REST API using a different method. Learn more about the Compass REST API
An event source represents a tool, such as Bitbucket, GitHub, Jenkins, or ArgoCD—connected to Compass that supplies events to a component's activity feed.
Compass uniquely identifies an event source based on externalEventSourceId
. We require externalEventSourceId
as an input on any request to create events.
For example, a Bitbucket repository creates events of multiple types such as build events and deployment events.
In this scenario, the externalEventSourceId
could be the Bitbucket repository's ID or URL, while the eventType
is deployment
or build
based on the type of event.
Today Compass supports the following event types:
You need an Atlassian API token to call the Compass REST API. Log in to https://id.atlassian.com/manage/api-tokens to create the API token.
Learn how to manage API tokens for your Atlassian account
Each event will need to be associated with a component. Learn how to find a component's ID
Here, we’ve used a cURL command as an example to show you how to call the REST API. You can also use another method to call the REST API.
This example sends an event of the custom
type to a component's activity feed. The Compass REST API supports many other event types. See the Compass REST API reference documentation for information about supported event types and event details for a particular event type.
This API is rate limited. Only 100 requests per user per minute are allowed.
Add this cURL command to your CI/CD tool, such as Bitbucket Pipelines or Github Actions, or run it in your terminal to call the REST API.
1 2curl \ --request POST \ --url https://example.atlassian.net/gateway/api/compass/v1/events \ --user "$USER_EMAIL:$USER_API_TOKEN" \ --header "Accept: application/json" \ --header "Content-Type: application/json" \ --data "{ \"cloudId\": \"$CLOUD_ID\", \"event\": { \"custom\": { \"updateSequenceNumber\": 1, \"displayName\": \"name\", \"description\": \"description\", \"url\": \"https://www.example.com\", \"lastUpdated\": \"$(date -u +'%Y-%m-%dT%H:%M:%SZ')\", \"externalEventSourceId\": \"$EXTERNAL_EVENT_SOURCE_ID\", \"customEventProperties\": { \"id\": \"1\", \"icon\": \"INFO\" } } }, \"componentId\": \"$COMPONENT_ID\", }"
On line number 3 --url https://example.atlassian.net/gateway/api/compass/v1/events \
, replace example
with your Compass site's name
On line number 4 --user "$USER_EMAIL:$USER_API_TOKEN" \
, specify your Atlassian account email address and Atlassian API token that you created earlier.
$USER_EMAIL
and $USER_API_TOKEN
as external environment variables, instead of hardcoding them into the script.On line number 8 \"cloudId\": \"$CLOUD_ID\"
, specify the cloud ID of your site. The component ID that you retrieved earlier contains the cloud ID (e.g.: in ari:cloud:compass:00000000-0000-0000-0000-0000:component/1111-1111-1111-1111-111111111111/22222222-2222-2222-2222-2222
the cloud ID value is 00000000-0000-0000-0000-0000
).
)
On line number 15 \"lastUpdated\": \"$(date -u +'%Y-%m-%dT%H:%M:%SZ')\"
, specify the timestamp when the event was sent. You can:
$(date -u +'%Y-%m-%dT%H:%M:%SZ')
with a specific timestamp following the ISO-8601 standard of YYYY-MM-DDThh:mm:ssZ
, where:
YYYY-MM-DD
represents the date in year, month, and dayT
is the delimiter between the date and the timehh:mm:ss
is the time in hours, minutes, and secondsZ
represents zero UTC offset\"timestamp\": \"2022-01-31T01:23:45Z\"
.On line number 16 \"externalEventSourceId\": \"$EXTERNAL_EVENT_SOURCE_ID\"
, specify the external event source ID. For example:
123e4567-e89b-12d3-a456-426614174000
)https://bitbucket.org/workspace-name/repository-name
)deploy-test-component
)On line number 23 \"componentId\": \"$COMPONENT_ID\"
, specify the component ID this event belongs to as you retrieved earlier (e.g.: ari:cloud:compass:00000000-0000-0000-0000-0000:component/1111-1111-1111-1111-111111111111/22222222-2222-2222-2222-2222
).
Run the cURL command in:
If the command is successful, you’ll see the event on your component’s activity feed in Compass.
Use the cURL command by adding it to your build system or deployment scripts to automatically send events to the activity feed of your component.
There are some nuances to keep in mind when working with events.
updateSequenceNumber
must be incremented per unique event. Otherwise, the request will be ignored.buildProperties.pipeline.pipelineId
needs to be unique per build event. Otherwise, any existing event with a matching pipelineId
will be overwritten instead.deploymentProperties.pipeline.pipelineId
, deploymentProperties.environment.environmentId
, and deploymentProperties.sequenceNumber
needs to be unique per deployment event. Otherwise, any existing event with matching values will be overwritten instead.Rate this page: