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

Credentials are used inside a `script` block with string concatenation and Jenkins warns about insecure interpolation.

BeginnerScenarioJenkins Shared Libraries, Credentials and Security
Answer

Situation read → Groovy interpolates "${SECRET}" before the shell runs, leaking into process arguments and logs.

What I'd do →

  1. Use single-quoted shell strings and let the shell read $SECRET from the environment.
  2. Pass secrets via stdin or a file where tools allow, e.g. docker login -u "$U" --password-stdin <<< "$P".

Why → The secret stays in the environment, not in the Groovy-expanded command line.

Interview tip → Be ready to explain Groovy vs shell interpolation in one sentence.

All CI/CD questions

More on Jenkins Shared Libraries, Credentials and Security