DevOps Engineer Interview Question

How do you handle secrets in a build and deployment pipeline?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Keep long lived credentials out of the pipeline entirely. Use workload identity federation so the CI job exchanges a short lived OIDC token for a scoped role, and pull application secrets at runtime from a secrets manager rather than injecting them at build time. Scope each secret to one environment and one consumer, rotate automatically, audit access, and mask them in logs. Never bake secrets into images or commit them, even encrypted, without key management.

Why interviewers ask this

Secret handling is where a lot of otherwise solid pipelines quietly fail an audit. The interviewer wants to hear a modern answer built on short lived credentials rather than a vault of static keys pasted into CI settings. They also want to see you think about the whole lifecycle: distribution, rotation, revocation, and what happens when a secret leaks, not just where it is stored.

How to structure your answer

  • Lead with eliminating long lived credentials via federated identity.
  • Separate build time from runtime secret needs.
  • Cover scoping, rotation and auditability.
  • Say what you do when one leaks.

Example answer

Spoken example, first person

My starting position is that the pipeline should not hold any long lived cloud credentials. The CI provider issues a signed identity token for the job, the cloud trusts that issuer, and the job exchanges it for a role that lasts minutes and is scoped to one environment. That deletes the whole category of a leaked static key sitting in a repository setting for three years. Application secrets are a separate concern and they belong at runtime, pulled from a secrets manager by the workload using its own identity, so a database password never passes through the build at all. If I have to keep encrypted secrets in git, for example in a GitOps repository, they are encrypted against a key management service so the decryption right is what I am really controlling, not the file. Everything is scoped narrowly, rotated on a schedule, and access is logged. And I plan for leaks: revoke first, rotate, then work out the blast radius from the audit trail, because trying to prove nobody used it before revoking is the wrong order.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How would you rotate a database credential with zero downtime?
  • How do you keep secrets out of application logs and crash dumps?
  • What is your approach to secrets in a GitOps repository?

Related devops engineer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot