The Simplest Way to Make Buildkite and Google Pub/Sub Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You pair buildkite and google pub/sub to trigger build jobs and stream pipeline events. This setup lets your team run fast builds and track job status in real time. Buildkite runs your test and deploy agents on your own cloud servers. Google Pub/Sub moves event messages between your cloud apps without dropping data. When you link them, your pipelines react to cloud changes right away. Your cloud apps can also read build results as soon as jobs finish. How buildkite and google pub/sub share ev

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You pair buildkite and google pub/sub to trigger build jobs and stream pipeline events. This setup lets your team run fast builds and track job status in real time.

Buildkite runs your test and deploy agents on your own cloud servers. Google Pub/Sub moves event messages between your cloud apps without dropping data. When you link them, your pipelines react to cloud changes right away. Your cloud apps can also read build results as soon as jobs finish.

How buildkite and google pub/sub share events and roles

Data flows between these two tools in two main ways. First, Buildkite sends job events out to a Pub/Sub topic. Second, a Pub/Sub topic pushes messages to start a new Buildkite job.

To send events out, you set up Buildkite notifications or agent hooks. When a build starts or fails, the agent writes a message to Pub/Sub. Downstream apps read that message to update dashboards or page the on-call team.

To trigger builds from the cloud, an app writes a message to a topic. A small cloud worker reads the message and calls the Buildkite API. That API call starts the right pipeline with the payload from the message.

Both flows need cloud roles and keys to log in. When your Buildkite agent runs on Google Cloud, use attached service accounts. The agent gets a short-lived token from the cloud metadata server. If your agent runs elsewhere, use workload identity federation to trade tokens. This removes the need to store static JSON key files on build servers.

Common failure modes and how to scope permissions

Teams often make mistakes when they set up keys for these workflows. The most common flaw is sharing one service account across all build agents. If one test pipeline leaks that key, an attacker can reach every topic. Another bad habit is giving the build agent the broad Pub/Sub Editor role.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged messages also cause headaches during an outage. If any developer can push a raw message to trigger a deploy, audits fail. You cannot tell who started the job or why the build ran.

You can fix these gaps with strict role and network rules. Give each Buildkite pipeline queue its own cloud service account. Grant only the publish role on the single topic that queue needs. Never let a test agent read from topics that hold production data.

Lock down your network paths between the build agents and Google Cloud APIs. Run your Buildkite agents inside a private cloud network with Private Google Access. This keeps all message traffic off the public internet. Turn on Cloud Audit Logs for your topics to track who sends messages. Also check that build logs do not print raw message payloads with secrets. If messages contain emails, phone numbers, card numbers, or national IDs, mask them first. Masking rewrites matched fields in results so sensitive data stays out of logs.

Keeping message schemas and dead letters clean

Fast event pipelines break when a message has the wrong format. If an app sends bad data, the build script might crash in a loop. Pub/Sub will keep trying to send the bad message over and over.

You can stop retry loops by setting up a dead-letter topic. When a message fails a few times, Pub/Sub moves it to this backup queue. Your team can inspect the broken payload and fix the bug without blocking builds. You can also attach a schema rule to your topic. The topic checks each message format before accepting it from the sender.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How do I let Buildkite publish to Pub/Sub without static keys?

Run your Buildkite agents on Google Cloud compute instances with a scoped service account. If agents run outside Google Cloud, set up workload identity federation to trade tokens.

Can Google Pub/Sub trigger a Buildkite pipeline directly?

Pub/Sub push subscriptions cannot add the custom auth headers that the Buildkite API requires. Instead, route the message through a small cloud function that calls the Buildkite API.

How should we scope IAM roles for build agents using Pub/Sub?

Create a dedicated service account for each agent queue and assign topic-level roles. Grant only the Publisher role on the single topic that specific pipeline needs.

The query runs. The emails stay hidden.