---
title: "Jenkins"
description: "Use Ennote secrets in Jenkins pipelines: store an Ennote token as a Secret text credential, bind it with credentials() in a Jenkinsfile, and inject secrets into build and deploy steps with ennote secret get."
canonical_url: "https://docs.ennote.io/guides/ci-cd/jenkins"
---
# Jenkins

> Use Ennote secrets in Jenkins pipelines: store an Ennote token as a Secret text credential, bind it with credentials() in a Jenkinsfile, and inject secrets into build and deploy steps with ennote secret get.

## How it works

Jenkins stores one Ennote token as a credential. The Jenkinsfile binds it to `ENNOTE_TOKEN`, and `ennote secret get <secret> -- <command>` runs each 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 Jenkins

Open **Manage Jenkins → Credentials**, choose a store and domain (for example **System → Global credentials**), and click **Add Credentials**:

- **Kind:** Secret text
- **Secret:** the token
- **ID:** `ennote-token`

## 3. Install the CLI on your agents

Jenkins agents usually run as the `jenkins` user without root, so the install script cannot write to `/usr/local/bin`. Install the CLI once on each agent, or in the image your agents run, as root:

```bash
curl -sSfL https://get.ennote.io/get-cli.sh | sh
```

You can also install the `.deb`, `.rpm` or `.apk` package from the [releases page](https://github.com/ennote-io/ennote-cli/releases/latest), for example with your configuration management tool.

## 4. Add the Jenkinsfile

```groovy [Jenkinsfile]
pipeline {
  agent any

  environment {
    ENNOTE_TOKEN           = credentials('ennote-token')
    ENNOTE_ORGANIZATION_ID = 'org_123'
    ENNOTE_WORKSPACE_ID    = 'wrk_prod'
    ENNOTE_DO_NOT_TRACK    = '1'
  }

  stages {
    stage('Migrate') {
      steps {
        sh 'ennote secret get db-credentials -- npm run migrate'
      }
    }
    stage('Deploy') {
      when { branch 'main' }
      steps {
        sh 'ennote secret get aws -- ./deploy.sh'
      }
    }
  }
}
```

Replace `org_123`, `wrk_prod`, `db-credentials` and `aws` with your organization ID, workspace ID and secret names. `credentials()` makes the token available only during the build and masks it in the console log. `when { branch 'main' }` works in Multibranch Pipeline jobs; in a regular Pipeline job, remove it.

## Docker Agents

If your stages run in a Docker agent, install the CLI in the image you build for CI:

```dockerfile [Dockerfile]
FROM node:22
RUN curl -sSfL https://get.ennote.io/get-cli.sh | sh
```

```groovy [Jenkinsfile]
pipeline {
  agent { docker { image 'my-registry/ci-node:22' } }
  // environment and stages as above
}
```

## FAQ

### Can I scope the token to one job?

Yes. Store the credential in a folder's credentials store instead of the global one, so only jobs in that folder can use it.

### Do I need `ennote auth login` on the agent?

No. With `ENNOTE_TOKEN` set, the CLI authenticates headlessly ([ennote auth](https://docs.ennote.io/cli/commands/auth)).

<need-help>



</need-help>


## Sitemap

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