What are the top Jenkinsfile best practices you follow?
IntermediateConceptBest practices & rapid-fire commands
Answer
- Declarative syntax, logic in shared libraries, small
scriptblocks agent noneat top when stages need different agents or approvals existtimeouton the pipeline and on everyinputbuildDiscarder,disableConcurrentBuilds(abortPrevious: true)for PRs- Single-quoted
shwith credentials bound narrowly - Heavy work in
shon agents, not in Groovy - Fail fast: cheap checks first,
failFaston parallel - Build once, promote the same artifact; never rebuild per environment
post { always { junit ... } cleanup { cleanWs() } }
More on Best practices & rapid-fire commands
What are the top controller best practices?IntermediateRapid-fire: how do you get the initial admin password?BeginnerRapid-fire: how do you list installed plugins and their versions?BeginnerRapid-fire: how do you trigger a parameterized build with curl and follow it?BeginnerRapid-fire: how do you run the controller in Docker for a quick test?BeginnerRapid-fire: how do you connect an inbound agent with Docker?Beginner