How do you integrate Jenkins with HashiCorp Vault or a cloud secret manager?
AdvancedConceptCredentials & security
Answer
Two patterns:
- Credentials provider: plugins such as AWS Secrets Manager Credentials Provider or Kubernetes Credentials Provider expose external secrets as normal Jenkins credentials (read-only, never stored in
JENKINS_HOME). - Runtime fetch: the HashiCorp Vault plugin's
withVaultstep reads secrets during the build, authenticating with AppRole or Kubernetes auth.
withVault(configuration: [vaultUrl: 'https://vault:8200', vaultCredentialId: 'vault-approle'],
vaultSecrets: [[path: 'secret/shack/prod', secretValues: [[envVar: 'DB_PASS', vaultKey: 'db_password']]]]) {
sh './migrate.sh'
}
More on Credentials & security
What credential types does Jenkins support out of the box?BeginnerWhat is the difference between Global and System credential scope?IntermediateHow do folder-scoped credentials help multi-team controllers?IntermediateHow does Jenkins mask secrets in logs and what are its limits?AdvancedWhat authorization strategies are available?IntermediateWhat are the key permissions to understand in matrix auth?Intermediate