If you want to configure your Bamboo pipeline to send an event to a Compass component for a build event, follow these steps.
1 2#!/bin/bash set -e CLOUD_ID="your-cloud-id" COMPONENT_ID="your-component-id" COMPASS_USER_EMAIL="your-email" COMPASS_USER_API_KEY="your-api-key" NAME=${bamboo.buildPlanName} START=${bamboo.buildTimeStamp} SEQ=${bamboo.buildNumber} DESCRIPTION=${bamboo.planName} URL=${bamboo.buildResultsUrl} EXTERNAL_ID=${bamboo.planRepository.branchDisplayName} PIPELINE_ID=${bamboo.buildNumber} START=$(date +%s) curl --request POST \ --url https://hello.atlassian.net/gateway/api/compass/v1/events \ --user "$COMPASS_USER_EMAIL:$COMPASS_USER_API_KEY" \ --header "Accept: application/json" \ --header "Content-Type: application/json" \ --data "{ \"cloudId\": \"$CLOUD_ID\", \"event\": { \"displayName\": \"$NAME\", \"lastUpdated\": \"$START\", \"updateSequenceNumber\": $SEQ, \"description\": \"$DESCRIPTION\", \"url\": \"$URL\", \"externalEventSourceId\": \"$EXTERNAL_ID\", \"buildProperties\": { \"state\": \"IN_PROGRESS\", \"pipeline\": { \"pipelineId\": \"$PIPELINE_ID\", }, \"startedAt\": $START } }, \"componentId\": \"$COMPONENT_ID\" }"
Fill in the values for your Compass site’s cloud ID, the ID of the component you intend to send the event to, your email, and API key.
The CURL request being used is explained in our REST API documentation.
The variables being used here are provided to us by Bamboo, see here. There are various other predefined variables that could be substituted as per your preferences.
1 2#!/bin/bash set -e CLOUD_ID="your-cloud-id" COMPONENT_ID="your-component-id" COMPASS_USER_EMAIL="your-email" COMPASS_USER_API_KEY="your-api-key" NAME=${bamboo.buildPlanName} START=${bamboo.buildTimeStamp} SEQ=${bamboo.buildNumber} DESCRIPTION=${bamboo.planName} URL=${bamboo.buildResultsUrl} EXTERNAL_ID=${bamboo.planRepository.branchDisplayName} PIPELINE_ID=${bamboo.buildNumber} LAST_UPDATED=$(date +%s) STATUS="SUCCESSFUL" # default to success # Example logic to determine build status based on previous tasks # This assumes you have control over the tasks and their exit codes if [ $? -ne 0 ]; then STATUS="FAILED" fi curl --request POST \ --url https://hello.atlassian.net/gateway/api/compass/v1/events \ --user "$COMPASS_USER_EMAIL:$COMPASS_USER_API_KEY" \ --header "Accept: application/json" \ --header "Content-Type: application/json" \ --data "{ \"cloudId\": \"$CLOUD_ID\", \"event\": { \"displayName\": \"$NAME\", \"lastUpdated\": \"$LAST_UPDATED\", \"updateSequenceNumber\": $SEQ, \"description\": \"$DESCRIPTION\", \"url\": \"$URL\", \"externalEventSourceId\": \"$EXTERNAL_ID\", \"buildProperties\": { \"state\": \"$STATUS\", \"pipeline\": { \"pipelineId\": \"$PIPELINE_ID\", }, \"startedAt\": $START } }, \"componentId\": \"$COMPONENT_ID\" }"
Now, your Bamboo pipeline should be configured to send build events to a Compass component of your choosing, and update the event with the correct status once the build concludes.
Rate this page: