---
title: "Google Cloud Build"
description: "Use Ennote secrets in Google Cloud Build: keep the Ennote token in Google Secret Manager, expose it to build steps with availableSecrets and secretEnv, and inject secrets with ennote secret get."
canonical_url: "https://docs.ennote.io/guides/ci-cd/google-cloud-build"
---
# Google Cloud Build

> Use Ennote secrets in Google Cloud Build: keep the Ennote token in Google Secret Manager, expose it to build steps with availableSecrets and secretEnv, and inject secrets with ennote secret get.

## How it works

The Ennote token is kept in Google Secret Manager. `cloudbuild.yaml` exposes it to a step as `ENNOTE_TOKEN` with `availableSecrets` and `secretEnv`. The step installs the Ennote CLI, and `ennote secret get <secret> -- <command>` runs your command with the keys of the secret as environment variables. See the [CI/CD overview](https://docs.ennote.io/guides/ci-cd/overview) for the common setup.

## 1. Create a token

Create a [Personal Access Token](https://docs.ennote.io/docs/auth/user-tokens) with an expiration, and copy it.

## 2. Store it in Secret Manager

```bash
printf '%s' "<YOUR_ENNOTE_TOKEN>" | gcloud secrets create ennote-ci-token --data-file=-
```

Or create it in the Cloud Console: **Security → Secret Manager → Create secret**.

## 3. Allow Cloud Build to read it

Grant the **Secret Manager Secret Accessor** role on the secret to the service account your builds run as:

```bash
gcloud secrets add-iam-policy-binding ennote-ci-token \
  --member="serviceAccount:<BUILD_SERVICE_ACCOUNT_EMAIL>" \
  --role="roles/secretmanager.secretAccessor"
```

## 4. Add the build config

Each Cloud Build step runs in its own container, and only the `/workspace` directory is kept between steps. Install the CLI and run your command in the **same step**:

```yaml [cloudbuild.yaml]
steps:
  - id: migrate-and-deploy
    name: node:22
    entrypoint: bash
    args:
      - -c
      - |
        curl -sSfL https://get.ennote.io/get-cli.sh | sh
        ennote secret get db-credentials -- npm run migrate
        ennote secret get app -- npm run deploy
    env:
      - ENNOTE_ORGANIZATION_ID=org_123
      - ENNOTE_WORKSPACE_ID=wrk_prod
      - ENNOTE_DO_NOT_TRACK=1
    secretEnv:
      - ENNOTE_TOKEN

availableSecrets:
  secretManager:
    - versionName: projects/$PROJECT_ID/secrets/ennote-ci-token/versions/latest
      env: ENNOTE_TOKEN
```

Replace `org_123`, `wrk_prod`, `db-credentials` and `app` with your organization ID, workspace ID and secret names. The `node:22` image runs as root and includes `curl`. For deployments with `gcloud`, use the `gcr.io/google.com/cloudsdktool/cloud-sdk` image the same way.

<note>

Cloud Build replaces `$NAME` in `args` with build substitutions. If a command in your script uses a shell variable, write it as `$$NAME`.

</note>

## Several Steps

To use the CLI in several steps without downloading it each time, install it into `/workspace` once. That directory is shared between steps:

```yaml [cloudbuild.yaml]
steps:
  - id: install-ennote
    name: node:22
    entrypoint: bash
    args: ['-c', 'curl -sSfL https://get.ennote.io/get-cli.sh | sh && cp /usr/local/bin/ennote /workspace/ennote']

  - id: test
    name: node:22
    entrypoint: bash
    args: ['-c', './ennote secret get test-env -- npm test']
    env: ['ENNOTE_ORGANIZATION_ID=org_123', 'ENNOTE_WORKSPACE_ID=wrk_ci', 'ENNOTE_DO_NOT_TRACK=1']
    secretEnv: ['ENNOTE_TOKEN']

availableSecrets:
  secretManager:
    - versionName: projects/$PROJECT_ID/secrets/ennote-ci-token/versions/latest
      env: ENNOTE_TOKEN
```

## FAQ

### Is the token shown in build logs?

No. Values from `secretEnv` are not printed by Cloud Build. Don't echo the token or values fetched by `ennote secret get` in your scripts.

### Do I need `ennote auth login`?

No. With `ENNOTE_TOKEN` set, the CLI authenticates headlessly ([ennote auth](https://docs.ennote.io/cli/commands/auth)).

<need-help>



</need-help>


## Sitemap

See the full [sitemap](https://docs.ennote.io/sitemap.md) for all pages.
