Interview Prep/CI/CD/Jenkins Pipelines and Agents

A stage needs a specific JDK version and a database for integration tests, but the agent has neither. How do you provide them?

IntermediateScenarioJenkins Pipelines and Agents
Answer

Situation read → The build needs sidecar services plus a pinned runtime.

What I'd do →

  1. On Kubernetes agents, define a pod template with containers maven (JDK 21) and postgres:16; reach the DB at localhost:5432 since containers share a pod network.
  2. On Docker agents, start the DB with Testcontainers inside the test run, or docker run in a withRun block.
  3. Wait for readiness (pg_isready) before tests.

Why → Disposable dependencies give isolated, repeatable integration tests with no shared test database.

Interview tip → Testcontainers over a shared QA DB is a strong answer.

All CI/CD questions

More on Jenkins Pipelines and Agents