Make sure TC_CLOUD_TOKEN is set to your corresponding token value, download the agent and start it.
To use Testcontainers Cloud with Google Cloud Build you need to set TC_CLOUD_TOKEN to your corresponding service account token. You can generate the token in the Testcontainers Cloud dashboard. You can store your service account token securely in Google Cloud Secrets Manager. Once the secret is created, grant access to the principal YOUR_PROJECT_ID@cloudbuild.gserviceaccount.com , and assign the Secret Manager Secret Accessor role to it.
Next you need to install and start Testcontainers Cloud agent by setting TC_CLOUD_TOKEN environment variable by looking up the value from Google Cloud Secrets Manager.
You can use the following script for your cloudbuild.yaml configuration:
steps:
- name: "docker-image:tag" # ex: maven:3-eclipse-temurin-19
args:
- "-c"
- |
curl -fsSL https://app.testcontainers.cloud/bash | bash
cp ~/.testcontainers.properties /root/.testcontainers.properties
# Your test command like "mvn test" or "npm test"
dir: "${_APP_NAME}"
entrypoint: bash
secretEnv:
- TC_CLOUD_TOKEN
availableSecrets:
secretManager:
- versionName: projects/<PROJECT_ID>/secrets/TC_CLOUD_TOKEN/versions/latest
env: TC_CLOUD_TOKEN