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