Workload Secrets Vault in CI/CD Pipelines
This feature is currently available only to customers participating in a Private Preview. If you'd like to participate and be among the first to try this feature, ask our support or account team for details.
These examples show common ways to use Workload Secrets Vault from a build or deployment pipeline. They're written as Bash steps that call the Delinea CLI, so they work in any CI system that can run a Linux shell. Paths, names, and hosts are examples; replace them with your own.
Signing In from a Pipeline
Every example starts with the pipeline signed in as its own service user. Store the service user's username and password as protected variables in your CI system, and start each job like this:
set -euo pipefail
delinea start
echo "$WS_CLIENT_SECRET" | delinea login --tenant "$WS_TENANT" --client-id "$WS_CLIENT_ID" --client-secret-file -
delinea status
-
The Linux CLI needs glibc 2.39 or later. If your build agents are older, run the CLI in an Ubuntu 24.04 container.
-
In containers, you can set the Signing In with Environment Variables instead of running
delinea login. -
Mask every secret value in the job log with your CI system's masking feature, for example
echo "##vso[task.setsecret]$value"in Azure Pipelines orecho "::add-mask::$value"in GitHub Actions. Masking hides values in the log only; the value still exists in the job's memory and environment.
Example 1: Read a Database Password at Deploy Time
The repository keeps only a settings template with no values. The deploy step reads the password from Workload Secrets Vault and passes it to the application in its environment, so the application doesn't need to change.
secret=$(delinea --json workload secret get apps/orders/prod/db)
DB_USER=$(jq -er '.data.data.username' <<< "$secret")
DB_PASSWORD=$(jq -er '.data.data.password' <<< "$secret")
export DB_USER DB_PASSWORD
echo "##vso[task.setsecret]$DB_PASSWORD"
./start-app.sh
The pipeline needs Read Secret and a policy that allows read on secret/apps/orders/prod/db. The only standing credential in the CI system is the pipeline's own sign-in.
jq -e fails when a field is missing, so the job stops instead of starting the application with the text null. Assign each value to a variable before you export it, because export NAME=$(...) hides the failure.
Example 2: Recover from a Bad Rotation
A rotation job writes a new password, but the database never received it. Record the version that works before you rotate, and roll back if the application can't connect:
path=apps/orders/prod/db
good=$(delinea --json workload secret describe "$path" | jq -r '.data.metadata.version')
trap 'delinea --json workload secret rollback "$path" --version "$good"' ERR
data=$(jq -n --arg pw "$NEW_PASSWORD" '{username: "orders_app", password: $pw}')
delinea --json workload secret create "$path" --data "$data"
./check-db-connection.sh # fails, so the trap rolls back to the version that worked
A rollback adds a new version with the old data; the bad version stays in the history for review. The job needs read, create, and update on the path, and the Read Secret, Create Secret, and Update Secret permissions.
Example 3: Least Privilege for One Pipeline
Give a pipeline a broad read grant for its application, a narrow write grant for rotation, and a deny for a branch it must never touch:
{ "name": "orders-ci-read", "effect": "allow", "actions": ["read", "list"],
"subjects": ["upn:orders-ci@example.com"], "targets": ["secret/apps/orders/*"] }
{ "name": "orders-ci-rotate", "effect": "allow", "actions": ["create", "update"],
"subjects": ["upn:orders-ci@example.com"], "targets": ["secret/apps/orders/prod/db"] }
{ "name": "orders-ci-no-payroll", "effect": "deny", "actions": ["read", "list", "create", "update", "delete"],
"subjects": ["upn:orders-ci@example.com"], "targets": ["secret/apps/orders/payroll", "secret/apps/orders/payroll/*"] }
With these policies, the pipeline can read apps/orders/prod/db but not apps/orders/payroll/db, because the deny wins. It can't write anywhere except the rotation path, and it can't delete anything. A denied request returns 403 without naming the policy, so test each grant after you set it up.
Example 4: Pass an Encrypted Configuration Between Jobs
A build job renders a configuration file that contains secrets and publishes only ciphertext as a build artifact. A later deploy job decrypts it. Anyone who can download the artifact sees only ciphertext.
# Build job: encrypt and publish only the ciphertext
delinea --json workload crypto auto encrypt --path apps/orders/deploy-config \
--plaintext="$(cat deploy.env)" | jq -r '.ciphertext' > "$ARTIFACT_DIR/deploy.env.enc"
rm deploy.env
# Deploy job: decrypt
delinea --json workload crypto auto decrypt --path apps/orders/deploy-config \
--ciphertext "$(cat deploy.env.enc)" | jq -r '.plaintext' > deploy.env
Create the key once with crypto auto key create apps/orders/deploy-config. Give the build job only encrypt and the deploy job only decrypt on cryptokey/apps/orders/deploy-config. Payloads can be up to 64 KiB. See Encryption as a Service.
Example 5: Hand Over a Credential to a Person
A provisioning pipeline creates an account and needs to give its first password to the account's owner. Instead of printing the password in the log, the pipeline creates a one-view share:
share=$(delinea --json workload crypto share create --plaintext="$INITIAL_PASSWORD" \
--passphrase="$HANDOVER_PASSPHRASE" --ttl-seconds 86400 --max-views 1)
token=$(jq -r '.token' <<< "$share")
echo "##vso[task.setsecret]$token"
./notify-owner.sh "$token" # send the token to the owner, and the passphrase separately
The owner signs in to the same tenant and redeems the share once with crypto share unwrap. The pipeline can later check with crypto share get whether the share has been redeemed. See Sharing Secrets with Secret Share.
Example 6: Prove a Pipeline's Identity with a Client Certificate
A service that accepts mutual TLS trusts one managed CA. The pipeline gets a one-hour client certificate from a template that allows only the pipeline's own name:
delinea --json workload pki template certificate create deploy-bot \
--common-name deploy-bot.payments.example.com --ttl-hours 1 > issued.json
jq -r '.certificate' issued.json | base64 -d > client.pem
jq -r '.privateKey' issued.json | base64 -d > client.key
rm issued.json
curl --cert client.pem --key client.key --cacert service-ca.pem https://deploy.payments.example.com/release
A request for another name or a longer lifetime is refused by the template. The pipeline needs the Create PKI Certificate permission. Store the CA certificate as an ordinary secret if the pipeline also needs it. See Managed Certificate Authorities.
Example 7: Use a Temporary Database Account
Instead of a stored password, each run gets its own MySQL account that's removed shortly after the run:
cred=$(delinea --json workload secret mint apps/orders/prod/db-read)
lease=$(jq -er '.data.leaseId' <<< "$cred")
trap 'delinea --json workload lease revoke "$lease"' EXIT # optional: remove the account when this step ends
DB_USER=$(jq -er '.data.credential.username' <<< "$cred")
DB_PASSWORD=$(jq -er '.data.credential.password' <<< "$cred")
export DB_USER DB_PASSWORD
echo "##vso[task.setsecret]$DB_PASSWORD"
./run-report.sh
Mint once per job and don't retry the mint automatically, because each mint creates a new account. To mint, the pipeline needs Read Secret and a policy that allows read on secret/apps/orders/prod/db-read.
The trap line is optional. It revokes the lease when the step ends, even if the step fails, so the account is removed soon after the run instead of when the lease expires. Revoking needs Delete Secret and a policy that allows revoke on lease/apps/orders/prod/db-read/*. See Dynamic Database Credentials and Leases and Revocation.
Example 8: Run Terraform as a Temporary Azure Identity
Each Terraform run gets a service principal that exists only for the lease, with a role on one resource group:
cred=$(delinea --json workload secret mint infra/prod/terraform-apply)
ARM_TENANT_ID=$(jq -er '.data.credential.tenantId' <<< "$cred")
ARM_CLIENT_ID=$(jq -er '.data.credential.clientId' <<< "$cred")
ARM_CLIENT_SECRET=$(jq -er '.data.credential.clientSecret' <<< "$cred")
export ARM_TENANT_ID ARM_CLIENT_ID ARM_CLIENT_SECRET
export ARM_SUBSCRIPTION_ID="<subscription-id>" # the subscription of the resource group; not part of the credential
echo "##vso[task.setsecret]$ARM_CLIENT_SECRET"
# Wait until Azure accepts the new credential (it can take 10 to 20 seconds)
for i in $(seq 1 12); do
az login --service-principal -u "$ARM_CLIENT_ID" -p "$ARM_CLIENT_SECRET" --tenant "$ARM_TENANT_ID" >/dev/null 2>&1 && break
sleep 10
done
terraform init -input=false
terraform apply -input=false -auto-approve
In the Terraform configuration, turn off resource provider registration in the azurerm provider. The minted service principal has rights on one resource group only, so it can't register resource providers for the subscription. The provider takes the subscription from ARM_SUBSCRIPTION_ID.
provider "azurerm" {
features {}
resource_provider_registrations = "none"
}
Set the dynamic secret's ttlSeconds long enough for the whole run. When the lease ends, the role assignment and the app registration are deleted. See Dynamic Azure Credentials.