> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# jenkinsfile-credential-interpolation

> A Jenkinsfile shell step interpolates a bound credential with a Groovy double-quoted string.

## What it flags

A `sh`, `bat`, `powershell` or `pwsh` step inside `withCredentials` whose double-quoted script interpolates a secret variable that the binding declares: `variable` of `string` and `usernameColonPassword`, `passwordVariable`, `passphraseVariable` and `secretKeyVariable`. Credentials bound in a declarative `environment` block (`TOKEN = credentials('id')`, which also defines `TOKEN_PSW`) count within the enclosing stage or pipeline. Groovy substitutes the secret into the command string, so it appears in the process list on the agent, can be read by other processes, and reaches the step's arguments; a secret that contains shell characters also changes the command. Jenkins reports the same pattern as insecure interpolation of sensitive variables. [Jenkins docs](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#interpolation-of-sensitive-environment-variables)

Not flagged: single-quoted scripts, where the shell reads the secret from the environment; usernames, key file paths and `file` or `zip` binding variables, which hold a path rather than the secret; the condition of a ternary, while each of its results is checked; and uses outside the `withCredentials` block or stage that binds the name.

```groovy theme={null}
withCredentials([string(credentialsId: 'api-token', variable: 'TOKEN')]) {
  sh 'curl -H "Authorization: Bearer $TOKEN" https://api.example.com'
}
```

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "jenkinsfile-credential-interpolation": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.