Interview Prep/CI/CD/Jenkins Shared Libraries, Credentials and Security

A Jenkins job must read secrets from HashiCorp Vault. How do you integrate it?

IntermediateScenarioJenkins Shared Libraries, Credentials and Security
Answer

Situation read → Dynamic secrets rather than static credentials.

What I'd do →

  1. Install the HashiCorp Vault plugin and configure the Vault URL and AppRole or Kubernetes auth.
  2. Use withVault([vaultSecrets: [[path: 'secret/app', secretValues: [[envVar: 'DB_PASS', vaultKey: 'password']]]]]) { sh '...' }.
  3. Give the Jenkins role a Vault policy that only reads the needed paths with a short TTL.

Why → Secrets are fetched at run time, audited by Vault, and never stored in Jenkins.

Interview tip → For databases prefer Vault dynamic credentials with a TTL equal to the build.

All CI/CD questions

More on Jenkins Shared Libraries, Credentials and Security