API

Environment Variables

How to use environment variables in PandaCI

See all available environment variables in the workflow environment.

You can also set your own environment variables using secrets.

Example

.pandaci/env.workflow.ts
import { docker, $, env } from "jsr:@pandaci/workflow";

docker("ubuntu:latest", () => {
  $`echo "Hello, world! from branch: ${env.PANDACI_BRANCH}"`;
});

Using custom types

You can use custom types to define your own environment variables.

.pandaci/custom-env.workflow.ts
import { docker, $, env as rawEnv, type Env } from "jsr:@pandaci/workflow";

const env = rawEnv as Env<{
  MY_ENV_VAR: string;
}>;

docker("ubuntu:latest", () => {
  // typesafe environment variable
  $`echo $MY_ENV_VAR`.env({ MY_ENV_VAR: env.MY_ENV_VAR });
});

Whilst you can pass the env object directly to the env method, we recommend only passing the specific environment variables you need to avoid leaking sensitive information.