Interview Prep/Jenkins/Pipeline design & Jenkinsfile decisions

Unit tests, lint, dependency audit and SAST run sequentially and take 22 minutes. How do you restructure the pipeline?

BeginnerScenarioPipeline design & Jenkinsfile decisions
Answer

Situation read → These checks are independent and can run concurrently.

What I'd do →

  1. Put them under one parallel stage with failFast true.
  2. If they share one pod, run them as parallel branches using different containers; if heavy, give each branch its own agent.
  3. Run the fastest check (lint, under 1 minute) also as a separate first stage so obvious failures stop the build before pods spin up.
    stage('Checks') { failFast true; parallel {
      stage('Unit') { steps { container('node') { sh 'npm test' } } }
      stage('Audit') { steps { container('node') { sh 'npm audit --audit-level=high' } } }
      stage('SAST') { steps { container('semgrep') { sh 'semgrep ci' } } }
    } }
    

Why → Wall time becomes the slowest branch instead of the sum.

Interview tip → Quote numbers: "22 minutes down to 8, the longest branch".

All Jenkins questions Roadmap: Jenkins

More on Pipeline design & Jenkinsfile decisions