---
title: "Azure DevOps"
description: "Use Ennote secrets in Azure DevOps Pipelines: store an Ennote token as a secret pipeline variable or in a variable group, map it into the step's environment, and inject secrets with ennote secret get."
canonical_url: "https://docs.ennote.io/guides/ci-cd/azure-devops"
---
# Azure DevOps

> Use Ennote secrets in Azure DevOps Pipelines: store an Ennote token as a secret pipeline variable or in a variable group, map it into the step's environment, and inject secrets with ennote secret get.

## How it works

Azure DevOps stores one Ennote token as a secret variable. The pipeline maps it into the step's environment, and `ennote secret get <secret> -- <command>` runs the 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 Azure DevOps

Choose one:

- **Pipeline variable:** edit the pipeline, click **Variables → New variable**, name it `ENNOTE_TOKEN`, paste the token and select **Keep this value secret**.
- **Variable group** (to share it between pipelines): open **Pipelines → Library → + Variable group**, add `ENNOTE_TOKEN`, click the lock icon to make it secret, and save. Link the group in your YAML as shown below.

## 3. Add the pipeline

```yaml [azure-pipelines.yml]
trigger:
  - main

pool:
  vmImage: ubuntu-latest

variables:
  - group: ennote            # only if you used a variable group
  - name: ENNOTE_ORGANIZATION_ID
    value: org_123
  - name: ENNOTE_WORKSPACE_ID
    value: wrk_prod
  - name: ENNOTE_DO_NOT_TRACK
    value: '1'

steps:
  - script: curl -sSfL https://get.ennote.io/get-cli.sh | sh
    displayName: Install the Ennote CLI

  - script: ennote secret get db-credentials -- npm run migrate
    displayName: Run database migrations
    env:
      ENNOTE_TOKEN: $(ENNOTE_TOKEN)

  - script: ennote secret get aws -- ./deploy.sh
    displayName: Deploy
    env:
      ENNOTE_TOKEN: $(ENNOTE_TOKEN)
```

<warning>

Azure DevOps does not pass secret variables to scripts automatically. Every step that runs `ennote` needs the `env: ENNOTE_TOKEN: $(ENNOTE_TOKEN)` mapping. Non-secret variables, such as the organization and workspace IDs, are passed automatically.

</warning>

Replace `org_123`, `wrk_prod`, `db-credentials` and `aws` with your organization ID, workspace ID and secret names. Microsoft-hosted Ubuntu agents allow `sudo`, so the install script works as is. On self-hosted agents without root, install the CLI on the agent once ([Installing the CLI](https://docs.ennote.io/guides/ci-cd/overview#installing-the-cli)).

## Staging and Production

With multi-stage pipelines, set `ENNOTE_WORKSPACE_ID` per stage:

```yaml [azure-pipelines.yml]
stages:
  - stage: Staging
    variables:
      ENNOTE_WORKSPACE_ID: wrk_staging
    jobs:
      - job: Deploy
        steps:
          - script: curl -sSfL https://get.ennote.io/get-cli.sh | sh
          - script: ennote secret get app -- ./deploy.sh
            env:
              ENNOTE_TOKEN: $(ENNOTE_TOKEN)
```

## FAQ

### Why is ENNOTE_TOKEN empty in my script?

The step is missing the `env:` mapping. Secret variables are only available to a script when mapped explicitly.

### Do Windows agents work?

The install script supports Linux and macOS. Use an `ubuntu-latest` or `macos-latest` agent for steps that run `ennote`.

<need-help>



</need-help>


## Sitemap

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