Jenkins
Builds authenticate with an ID token your Jenkins signs itself.
Builds authenticate with an ID token your Jenkins signs itself.
Identity proof
The token has to come from https://ci.acme.com/oidc, and its sub claim has to match the workload you named. We compare that claim byte for byte, with no wildcards.
Every token also has to name your workspace as its audience. Ask for this audience and no other. A token requested for two audiences fails every exchange.
Console fields
| Field | Example | Advanced | What it pins |
|---|---|---|---|
| Jenkins URL | https://ci.acme.com | no | Must be reachable from the internet for us to read its signing keys at /oidc. A folder-scoped credential publishes elsewhere, and connecting tells you the issuer it printed. |
| Subject | https://ci.acme.com/job/api/ | no | The credential's subject, exactly as Jenkins renders it. One containing BUILD_NUMBER matches a single build. |
The console also asks which project and environment this identity reaches and which role it gets, with the credential lifetime behind Advanced.
Trust
Built from the example answers above:
| What | Value |
|---|---|
| Issuer | https://ci.acme.com/oidc |
| Claim compared | sub |
| Subject | https://ci.acme.com/job/api/ |
| Identity name | jenkins-https-ci-acme-com-job-api |
We name the identity for you, so the form never asks for one.
Console snippet
// Credential 'penv-oidc': set its Audience to YOUR_WORKSPACE_ID
withCredentials([string(credentialsId: 'penv-oidc', variable: 'T')]) {
sh '''
C=$(T="$T" jq -n '{token:env.T}' | curl -sS "https://penv.cloud/api/v1/auth/oidc" \
-H 'content-type: application/json' --data-binary @- | jq -r .credential)
PENV_TOKEN="$C" penv pull
'''
}The snippet finishes with penv pull, which writes a file. We recommend penv run for a process; penv pull is for a host that needs a file on disk. Connect your CI has the wrapped step.
Related
- Machine identity
- Connect a Platform in the console
- Jenkins documentation: the subject is the value most often set wrong