Running Stages in parallel

A parallel block runs its stages at the same time. failFast true aborts the other branches as soon as one fails; the option parallelsAlwaysFailFast() does that for every parallel. The job runs on linux with a boolean parameter BREAK_AUDIT:

decl-parallel (excerpt): three checks at onceGroovy
    stage('Checks') {
      failFast true
      parallel {
        stage('Lint') {
          steps { sh 'sleep 6; echo "lint: ok at $(date +%T)"' }
        }
        stage('Unit tests') {
          steps { sh 'sleep 6; echo "tests: ok at $(date +%T)"' }
        }
        stage('Audit') {
          steps { sh 'sleep 2; echo "audit at $(date +%T)"; test "$BREAK_AUDIT" = false' }
        }
      }
    }

The sleeps stand in for real work. With the defaults (build 3), the branches finished in 8 seconds instead of 14 in sequence. Build 2 set BREAK_AUDIT=true; its log reads "Failed in branch Audit", "Sending interrupt signal to process" twice, then "Failed in branch" for Lint and Unit tests:

decl-parallel build 2 in the Pipeline graph: Audit failed, and failFast aborted Lint and Unit tests
decl-parallel build 2 in the Pipeline graph: Audit failed, and failFast aborted Lint and Unit tests

The branches shared agent-1's one executor and workspace as concurrent processes: fine for read-only checks, risky for steps that write the same files, which need their own agent or dir. Heavy branches also compete for a four-CPU host's cores (Sizing Agents). Build 1 failed too: $BREAK_AUDIT was still empty (Build Parameters).