Integrations

Azure DevOps

Pull secrets into Azure Pipelines with the dotEnv CLI and a scoped organization API key.

Back to all guides

Azure Pipelines can pull secrets from dotEnv Cloud the same way any CI system does: install the CLI, authenticate with an organization API key from a secret variable, and pull the variables your stage needs. This guide shows a YAML pipeline end to end.

Store the API key as a secret variable

In your pipeline or a variable group, add a secret variable named DOTENV_API_KEY. Secret variables are masked in logs and are not passed to scripts automatically. You map them into the step's environment explicitly, which is exactly what we want.

Install the CLI

On a Microsoft-hosted ubuntu-latest agent the install script runs as-is:

azure-pipelines.yml
- script: curl -sSL https://dotenv.cloud/install.sh | bash
  displayName: Install dotEnv CLI

Pull secrets

Map the secret variable into the step's environment with the env block, then pull a .env file:

azure-pipelines.yml
- script: dotenv pull my-app/production/api --output=.env
  displayName: Pull secrets
  env:
    DOTENV_API_KEY: $(DOTENV_API_KEY)

Here is a complete single-stage pipeline:

azure-pipelines.yml
trigger:
  - main
pool:
  vmImage: ubuntu-latest
steps:
  - script: curl -sSL https://dotenv.cloud/install.sh | bash
    displayName: Install dotEnv CLI
  - script: dotenv pull my-app/production/api --output=.env
    displayName: Pull secrets
    env:
      DOTENV_API_KEY: $(DOTENV_API_KEY)
  - script: npm ci && npm run build
    displayName: Build

Export into the step environment instead

If your build reads from the process environment, source shell exports inside the same step so they stay in scope:

azure-pipelines.yml
- script: |
    eval "$(dotenv export my-app/production/api --format=shell)"
    npm run build
  displayName: Build with secrets
  env:
    DOTENV_API_KEY: $(DOTENV_API_KEY)

Client-managed encryption

For client-managed projects, add a second secret variable for the encryption key and map it in as DOTENV_CLIENT_KEY, or pass --client-key with a path to a file you write earlier in the job. The CLI decrypts on the agent; the key is never uploaded.

For the GitLab equivalent, see GitLab CI, and review Securing CI/CD Pipelines for hardening.