List build triggers

List build triggers with the client libraries.

Code sample

Node.js

To authenticate to Cloud Build, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

async function listBuildTriggers(
  projectId = 'YOUR_PROJECT_ID' // Your Google Cloud Platform project ID
) {
  // Imports the Google Cloud client library
  const {CloudBuildClient} = require('@google-cloud/cloudbuild');

  // Creates a client
  const cb = new CloudBuildClient();

  // What project should we list triggers for?
  const request = {
    projectId,
  };

  const [result] = await cb.listBuildTriggers(request);
  console.info(JSON.stringify(result, null, 2));
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.