Interview Prep/CI/CD/Jenkins Pipelines and Agents

A feature branch pipeline must use a different config than main, but you do not want a second Jenkinsfile.

BeginnerScenarioJenkins Pipelines and Agents
Answer

Situation read → Same pipeline, branch-aware parameters.

What I'd do →

  1. Use env.BRANCH_NAME and when conditions, or compute values in an environment {} block with ternaries.
  2. Use env.CHANGE_ID to detect PRs and skip publish steps.
  3. Keep environment-specific values in config files or Helm values per environment, not in Groovy.

Why → One pipeline definition is easier to maintain and audit.

Interview tip → Config lives with the environment, logic lives in the pipeline.

All CI/CD questions

More on Jenkins Pipelines and Agents