Interview Prep/Jenkins/Best practices & rapid-fire commands

What are the top Jenkinsfile best practices you follow?

IntermediateConceptBest practices & rapid-fire commands
Answer
  • Declarative syntax, logic in shared libraries, small script blocks
  • agent none at top when stages need different agents or approvals exist
  • timeout on the pipeline and on every input
  • buildDiscarder, disableConcurrentBuilds(abortPrevious: true) for PRs
  • Single-quoted sh with credentials bound narrowly
  • Heavy work in sh on agents, not in Groovy
  • Fail fast: cheap checks first, failFast on parallel
  • Build once, promote the same artifact; never rebuild per environment
  • post { always { junit ... } cleanup { cleanWs() } }
All Jenkins questions Roadmap: Jenkins

More on Best practices & rapid-fire commands