GitHub Event payload forwarding?

All my searching around revealed no previous issues of this type.

I’m looking for the ability to access and tailor my pipelines’ behavior around the contents of the GitHub Event payload. I can’t find any way, in any Buildkite documentation nor in rooting through the pipeline settings, to actually observe the payload that fires it off. Any level of access would
suffice, even if just passing the blob as an envar to the agents.

I’m wondering if this is something that can be done, or if it’s planned anywhere? If it’s not, I’ll resubmit this as a feature request.

Sorry, I know this is a super old thread, and apologies we didn’t get to it sooner — but we wanted to check in and see if you figured this out?

There is a sneaky way to access the full webhook we received using the graphql api. Here’s a query which should work:

query {
  pipeline(slug: "my-org/my-pipeline") {
    builds(first: 10) {
      edges {
        node {
          source {
            name
            ...on BuildSourceWebhook {
              uuid
              headers
              payload
            }
          }
        }
      }
    }
  }
}

within a build or job you should be able to use the job’s $BUILDKITE_BUILD_ID environment variable in this query:

query {
  build(uuid: "$BUILDKITE_BUILD_ID") {
    source {
      name
      ...on BuildSourceWebhook {
        uuid
        headers
        payload
      }
    }
  }
}

Hey there!

Since posting this, I’m no longer with the company that had me facing this issue. However, I do appreciate your getting back to me and see this as a prime example of why I’ve enjoyed working in/with Buildkite. I’m hoping to be able to continue using it in the future!

1 Like

Whilst the graphql solution provided does work, it requires a personal API token to run the query.

I’d like to run this query as part of my pipeline, on an agent, and not have to ship my personal token to all the agents.

The reason I would like to run this query, is to get the output from payload, as it has the juicy “compare” link in it, which knows nice info about how many commits were in this payload. Which I believe is since the last time a webhook was sent.

Basically what I want to solve, is something other CI systems have already, which is the ability to run certain steps if certain files were changed as part of this payload event. I was hoping I could implement this is a local hook quite easily, if I had access to the data from the github payload.

Hey @tigris,

Thanks for posting and welcome!

Yeah, thats not something we can do at the moment, but it’s a really great use case! I will take this feedback and share it with the team and see if it’s something we can do.

Is there any progress on this? We need access to the before sha on a push event to be able to use monorepo diff with a linear git history.
It seems the GraphQL API is the only way to obtain the before field from the GitHub webhook. Similarly, we want to avoid placing Buildkite tokens on the runners.

Hey! :wave:

We don’t have any news on this particular request. Our product team is currently focusing on other priorities that are essential for our roadmap.

For now, the API remains the only available option to achieve the functionality you are looking for, although it’s understandable you don’t want to have a personal token for this.