Jenkins · Steps and credentials

Use credentials safely

Bind a stored secret to a variable for a block. Jenkins masks the value in the log.

withCredentials([string(credentialsId: 'api-token', variable: 'API_TOKEN')]) {
  sh 'curl -H "Authorization: Bearer $API_TOKEN" https://api.example.com/deploy'
}

Official Jenkins documentation

More steps and credentials commands

All steps and credentials commands · Jenkins cheatsheet

Was this page helpful?