1. Help Center
  2. Testcontainers Cloud for CI

How to use Testcontainers Cloud with Jenkins

Make sure TC_CLOUD_TOKEN is set to your corresponding token value, download the agent and start it.

To use Testcontainers Cloud with Jenkins first you need generate the token in the Testcontainers Cloud dashboard. Then you can store the token as a Secret as follows:

  • From Dashboard go to Manage Jenkins -> Manage Credentials
  • Under Stores scoped to Jenkins click on (globals) domain and Add Credentials
  • Provide the following values and click on Create
    • Kind: Secret text
    • Secret: YOUR_TOKEN_VALUE
    • ID: tc-cloud-token-secret-id

Next, you should configure your Jenkins Pipeline to look up the credentials and set the TC_CLOUD_TOKEN environment variable. You can use the Testcontainers Cloud agent installation script and start it before running your tests.

You can use the following configuration step for your Jenkinsfile before the pipeline executes the build tool command to run the tests. 

pipeline {
agent any

environment {
TC_CLOUD_TOKEN = credentials('tc-cloud-token-secret-id')

stages {
stage('TCC SetUp') {
steps {
sh "curl -fsSL https://get.testcontainers.cloud/bash | sh "
stage('Test') {
steps {
// run your test command