Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Questions on Deployment API - Send Events

andrew_pass
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2022

Hi,

We're trying to get events for deployments firing into Compass using the documentation here - 

https://developer.atlassian.com/cloud/compass/components/send-events-using-REST-API/

And 

https://developer.atlassian.com/cloud/compass/rest/api-group-events/#api-compass-v1-events-post

We've tried to get our Event ID but we're getting an error back (404) -

{
"errors": [
{
"type": "CREATE_EVENT_SOURCE_NOT_FOUND",
"message": "We could not create the event because the event source is not found. Please try again with the correct event source ID."
}
]
}

Is there something we're missing? 

Many thanks,

Andy

3 answers

2 votes
Patrick Brady
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 24, 2022

Hello Andy!
I'm one of the developers on Compass. Can you send along the mutation that you are using to create the event source and the query you are making to get the event? I want to double check that in the events query you are using the same externalEventSourceId you set in the createEventSource mutation not the eventSourceId of the actual event source that is returned by the mutation.

If that's not the case, having the queries will also help me debug what's going on :)

- Patrick

Filip Swiatczak
Contributor
March 25, 2022

Hi Patrick, I'm the dev doing this with Andy. 

Here are the 3 sequential Graphql queries we used as per (https://developer.atlassian.com/cloud/compass/components/send-events-using-REST-API/):

query example {

  tenantContexts(hostNames:["xxx.atlassian.net"]) {

    cloudId

  }

}

mutation createEventSource {

  compass {

    createEventSource(input: {

        cloudId: "xxx-052c863da88d",

          externalEventSourceId: "automationdeveloperportal",

            eventType: BUILD

     }) {

      eventSource {

        id

      }

      success

      errors {

        message

      }

    }

  }

}

 

mutation attachEventSource {

  compass {

    attachEventSource(input: {

eventSourceId: "ari:cloud:compass:f0dc5bce-c8ca-434d-82ec-052c863da88d:event-source/79d4aee6-1e97-4dec-9503-a5ff659cbfe8/f554180edcf52ca26f77307adab7082a63420603b9531bb7e46ea47406387812",

componentId: "ari:cloud:compass:f0dc5bce-c8ca-434d-82ec-052c863da88d:component/79d4aee6-1e97-4dec-9503-a5ff659cbfe8/be39c303-634f-474e-a4f5-1c80b75972da"

}) {

      success

      errors {

        message

      }

    }

  }

}

 

This is the Event post Body we are trying with:

{

  "cloudId": "xxx-052c863da88d",

  "event": {

    "deployment": {

      "updateSequenceNumber": 57,

      "displayName": "test1",

      "url": "https://xxx.uk/job/Automation/job/developer-portal/job/master/",

      "description": "test description",

      "lastUpdated": "2022-03-22T17:37:10Z",

      "externalEventSourceId": "automationdeveloperportal",

      "deploymentProperties": {

        "sequenceNumber": 39,

        "state": "PENDING",

        "pipeline": {

          "pipelineId": "12345",

          "url": "https://xxx.uk/job/Automation/job/developer-portal/job/master/",

          "displayName": "pipeline"

        },

        "environment": {

          "category": "PRODUCTION",

          "displayName": "abcd",

          "environmentId": "live"

        }

      }

    }

  }

}

Please note we are using externalEventSourceId: "automationdeveloperportal" which was the ID I've given to a jenkins pipeline we've intended as the source of events. It returns:

{

    "errors": [

        {

            "type": "CREATE_EVENT_SOURCE_NOT_FOUND",

            "message": "We could not create the event because the event source is not found. Please try again with the correct event source ID."

        }

    ]

}

We also tried with eventSourceID, ie the full ari:(...), or random abcd, same results. 

The only way I can confirm the event exists is by re-running attachEventSource and getting 'already attached' message. CreateEventSource appears idempotent. An event list query that returns both eventSourceId and externalEventSourceId could be handy. 

Thanks!

Like Taylor likes this
Filip Swiatczak
Contributor
March 25, 2022

Correction, I got it working. 

To the best of my reading, it is not mentioned explicitly that in REST API :

"event": {

     "type": {
has to match the TYPE declared in:
createEventSource(input: {eventType: TYPE
might be obvious to some but it took me looking at the EventSource Query in GraphQL, with 3 mandatory parts to locating the EventSource: 

ARGUMENTS

cloudId

ID!

 

eventType

CompassEventType!

externalEventSourceId

ID!


To realise this. Thanks! 

Like # people like this
Luke
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2022

HI Filip, Thanks for sharing the solution.

Looks like we need to improve our error message here. I've raised an improvement issue to update this error message, and we'll also add a note in the guide as well. 

- Luke - Compass Engineering Manager

Like # people like this
0 votes
Andrew Freedman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 23, 2022

Hi Andy,

From the REST API docs, did the event source setup work and return you an EVENT_SOURCE_ID? (Also, this is for Jenkins deployments, right? The example suggests using an event type of CUSTOM but you're better off using DEPLOYMENT in this case.)

— Andrew

andrew_pass
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2022

Hi Andrew, 

Thanks for the reply, we managed to get an EventSourceID however when we try to use it we get the error above.

Tried using both the Custom and Deployment types and both get kicked back.

Cheers,

Andy

Phill Pafford
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2023

facing the same issue, how did you resolve this?

0 votes
Dave Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 23, 2022

Hey Andy, we have one of our teams looking into it. Will get you an update as soon as we get to the bottom of it.

andrew_pass
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2022

Cheers Dave, much appreciated :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events