Feeding Jenkins deploy data to Compass events
Asked by hpatel21:

Are there any instructions on recording Jenkins generated data as deployment events in Compass? My attempts to input these via REST API have been unsuccessful. I'm trying to add this within a component thats linked to a bitbucket cloud repo.


Answers:
author: Andy Wong
body: Hi [@hpatel21](/t5/user/viewprofilepage/user-id/2932892) and [@Phill Pafford](/t5/user/viewprofilepage/user-id/704705)

There is a way to send Jenkins build data via a curl command. Shoutout to [@Dave Parrish _Atlassian_](/t5/user/viewprofilepage/user-id/853503) for investigating this.

The pre-conditions are that there is a Github post-commit hook that runs the following script that triggers a Jenkins build.

```
export BUILD_START_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')

echo "Starting Website build #{$BUILD_NUMBER} at ${BUILD_START_TIME}"
sleep 2s

export BUILD_FINISH_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')

curl \
    --request POST \
    --url https://<atlassian-site>.atlassian.net/gateway/api/compass/v1/events \
    --user "${ATLASSIAN_API_CREDENTIALS}" \
    --header "Accept: application/json" \
    --header "Content-Type: application/json" \
    --data "{
        \"cloudId\": \"ca4d6d1f-c9de-431f-9a40-6682e1968a11\",
        \"event\": {
            \"build\": {
                \"updateSequenceNumber\": ${BUILD_NUMBER},
                \"displayName\": \"Website build ${BUILD_NUMBER}\",
                \"description\": \"Build ${BUILD_NUMBER} of Website\",
                \"url\": \"${BUILD_URL}\",
                \"lastUpdated\": \"${BUILD_FINISH_TIME}\",
                \"externalEventSourceId\": \"<your-jenkins-source-id>\",
                \"buildProperties\": {
                \"state\": \"SUCCESSFUL\",
                \"pipeline\": {
                    \"pipelineId\": \"${BUILD_NUMBER}\",
                    \"url\": \"${BUILD_URL}\",
                    \"displayName\": \"Pipeline ${BUILD_NUMBER} of Website\"
                },
                \"startedAt\": \"${BUILD_START_TIME}\",
                \"completedAt\": \"${BUILD_FINISH_TIME}\"
            }
        }
    }
}"

echo "Finished Website build #{$BUILD_NUMBER} at ${BUILD_FINISH_TIME}"?
```

comments: author: Phill Pafford
body: Hi Andy,

I have the exact same curl command, the only thing that differs is the \`externalEventSourceId\` but all I ever get is this response, any chance you ran into this and have a solution to solve it?

NOTE: I did follow the graphql commands and created the custom event type

```
{

  "errors": [

 {

    "type": "CREATE_EVENT_SOURCE_NOT_FOUND",

    "message": "We could not create the event because the event source is not found. Please check that the external event source ID and the type of event being submitted match the event source.If a Forge App ID was used during event source creation, please also check you are using the same Forge App ID when accessing the event source."

 }

 ]

}
```


author: Andy Wong
body: HI Phill, is the external event source ID you added correct? It looks like the request is incorrect or potentially permissions are not available for that said external source ID.


author: Phill Pafford
body: thanks Andy, I found my issue, I was using the ARN and not the static name I assign it


author: Mark Rekveld - Marvelution
body: Hi all,

I'm Mark developer of the Jenkins Integration for Jira app, and I'm currently looking to expose the data collected by the app to other Atlassian tools as well, like Compass.

The future Compass app would be an addition to the Jira app and would allow a seemless integration where the configuration of the integration can be managed in Jira and Compass.

Let me know if you would like to be part of a beta group to get first access to the Compass app, drop me a mail at support@marvelution.com.

Cheers,  
Mark

comments: author: Marcel Rossouw
body: Yes please!


author: Mark Rekveld - Marvelution
body: Noted [@Marcel Rossouw](/t5/user/viewprofilepage/user-id/5348233) please drop me a mail at support@marvelution.com so I can get in touch with you.


author: Mark Rekveld - Marvelution
body: [@Marcel Rossouw](/t5/user/viewprofilepage/user-id/5348233) and anyone else interested.

I'm getting closer to the first beta version of the Compass connector for the Jenkins Integration for Jira app.

Steps now are:

1. Install and configure the Jenkins Integration for Jira app
2. Install the Compass app.
3. Add a link to a Compass component to link the component to one or more jobs.

Up next are improved import flows, and data visualisation that also includes link suggestions within Compass and Jira.

Let me know if you want to try this and help shape the app.


author: Avinash Arun Deshpande
body: Hi Mark,

Do you have steps to complete the integration Jenkins with Compass?

If yes, could you please provide the same with me?

I am looking forward to hearing from you.

Thanks,  
Avinash


author: Mark Rekveld - Marvelution
body: Hi [@Avinash Arun Deshpande](/t5/user/viewprofilepage/user-id/3036912)

I'm working with Atlassian Support as we speak on the approval of my Jenkins for Compass app.

The full process after approval is given will be:

1. Install [Jenkins Integration for Jira](https://marketplace.atlassian.com/apps/1211376/jenkins-integration-for-jira?hosting=cloud&tab=overview) app (paid app)
2. Connect a Jenkins site in Jira and let the Jira app synchronize jobs and builds from Jenkins
3. Install the Jenkins for Compass app (free app)
4. Link Jenkins jobs with Compass Components, with suggestions from the build-issue index form the [Jenkins Integration for Jira](https://marketplace.atlassian.com/apps/1211376/jenkins-integration-for-jira?hosting=cloud&tab=overview) app

Any Jenkins results will be forwarded to Compass by the Jira app.

All update this comment as soon as approval is given and the Compass app is available.


author: Avinash Arun Deshpande
body: Hi Mark,

Could you please send me the link to Jenkins for Compass (free app)?


author: Mark Rekveld - Marvelution
body: [@Avinash Arun Deshpande](/t5/user/viewprofilepage/user-id/3036912) the Compass app is not public yet, this will only become public once Atlassian has approved it.

As soon as I can I'll share the app link with you.


author: Avinash Arun Deshpande
body: Thanks Mark.


author: Mark Rekveld - Marvelution
body: Hi [@Avinash Arun Deshpande](/t5/user/viewprofilepage/user-id/3036912)

The app has just been approved and you can get it [from the marketplace](here:?https://marketplace.atlassian.com/apps/1234756/jenkins-for-compass?hosting=cloud&tab=overview)

It is not yet listed in Compass itself, and I'm not sure how long this takes, but you can install it trough the Marketplace listing.

The docs are available [here](https://jjc.marvelution.com/docs/administration/compass-connector/)

Let me know if you run into any issues, have questions and/or comments

Cheers,  
Mark


author: hpatel21
body: Thanks, I was finally able to publish data calling the API using curl. The problem was with publishing to development environment instead of staging/production. Looks like development/testing environments are not supported out of the box.

comments: author: Eric Chauvin
body: yes, i have same trouble, we cannot view events published to development, so this tool is useless for now


author: Phill Pafford
body: I'm also looking for this as well. I did see some related repos that are interesting

* <https://github.com/atlassian-labs/compass-examples>
* <https://github.com/atlassian-labs/gitlab-for-compass>