Skip to content

[AIROCMLIR-597][CI] Extract Jenkinsfile helpers into helpers/*.groovy and load them in a Bootstrap stage#2360

Open
bogdan-petkovic wants to merge 3 commits intoROCm:developfrom
bogdan-petkovic:bogdan-petkovic/jenkins-helpers-extract
Open

[AIROCMLIR-597][CI] Extract Jenkinsfile helpers into helpers/*.groovy and load them in a Bootstrap stage#2360
bogdan-petkovic wants to merge 3 commits intoROCm:developfrom
bogdan-petkovic:bogdan-petkovic/jenkins-helpers-extract

Conversation

@bogdan-petkovic
Copy link
Copy Markdown
Contributor

@bogdan-petkovic bogdan-petkovic commented Apr 30, 2026

Motivation

The primary mlir/utils/jenkins/Jenkinsfile has grown to ~2000 lines, the majority of which are helper functions defined at the top of the file. This makes the actual pipeline definition hard to read and to navigate, and forces the same helpers to be duplicated across Jenkinsfile.downstream and Jenkinsfile.release (see the // ON CHANGING THESE, ALSO CHANGE Jenkinsfile.downstream markers). Extracting the helpers into a shared location is the first step toward eliminating that duplication.
Two earlier attempts addressed this problem but neither was merged:

  • #2092CI: Refactor Jenkinsfile helpers into implicit Shared Library — split the helpers into multiple files under a vars/ directory at the repo root. Clean per-domain separation, but the implicit-Shared-Library mechanism requires the Jenkins controller to be configured with a Global Pipeline Library.
  • #2276[AIROCMLIR-597][CI] Create PipelineHelpers and load them in Jenkinsfile via Bootstrap stage — collapsed every helper into a single PipelineHelpers.groovy and loaded it from a Bootstrap stage. Fully self-contained, but consolidates ~2000 lines into one file, which keeps the original navigability problem.
    This PR combines the strengths of both: it adopts CI: Refactor Jenkinsfile helpers into implicit Shared Library #2092's per-domain file split (helpers grouped by purpose into separate files) and [AIROCMLIR-597][CI] Create PipelineHelpers and load them in Jenkinsfile via Bootstrap stage #2276's load()-from-Bootstrap loading mechanism.

Technical Details

  • New mlir/utils/jenkins/helpers/ directory with six files: scmUtils, nodeUtils, buildUtils, testUtils, reportUtils, ciLogic — 37 helpers total.
  • New Bootstrap stage in Jenkinsfile does checkout scm, loads each helper file, and wires cross-helper handles via @Field
    (nodeUtils.scmUtils, testUtils.nodeUtils, testUtils.buildUtils).
  • All helper call sites in Jenkinsfile are namespaced (e.g. ciLogic.setHeartbeat()).
  • Jenkinsfile: 2012 → 1099 lines.
  • All extracted helpers are identical to develop except the cross-helper namespace prefixes and one deliberate shell bug fix in testUtils.collectCoverageData, per Copilot review on PR [AIROCMLIR-597][CI] Create PipelineHelpers and load them in Jenkinsfile via Bootstrap stage #2276 ([AIROCMLIR-597][CI] Create PipelineHelpers and load them in Jenkinsfile via Bootstrap stage #2276 (review)):
    -       if [ `df --output=avail -k . | tail -1l` -lt 153600000 ]; then
    +       if [ `df --output=avail -k . | tail -n 1` -lt 153600000 ]; then
    
  • Jenkinsfile.downstream and Jenkinsfile.release are unchanged here; a follow-up will migrate them so the // ON CHANGING THESE, ALSO CHANGE Jenkinsfile.downstream duplication can be removed.

Test Plan

  • Full CI matrix on this PR before marking it ready for review:
    • PR CI — default codepath
    • PR CI — mfma
    • PR CI — navi21
    • PR CI — navi3x
    • PR CI — navi4x
    • PR CI — vanilla
    • PR CI — gfx950
    • Nightly
    • Weekly

Test Result

Submission Checklist

… in a Bootstrap stage

Signed-off-by: bogdan-petkovic <bogdan.petkovic@htecgroup.com>
@bogdan-petkovic bogdan-petkovic force-pushed the bogdan-petkovic/jenkins-helpers-extract branch from 6cacfd3 to 947e828 Compare May 4, 2026 09:56
@bogdan-petkovic bogdan-petkovic marked this pull request as ready for review May 4, 2026 09:57
@bogdan-petkovic bogdan-petkovic requested a review from causten as a code owner May 4, 2026 09:57
@dorde-antic dorde-antic requested a review from Copilot May 4, 2026 12:26
Copy link
Copy Markdown
Contributor

@dorde-antic dorde-antic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the main CI pipeline definition by extracting Jenkinsfile helper logic into per-domain Groovy scripts under mlir/utils/jenkins/helpers/, then loading and wiring those helpers in a new Bootstrap stage. This reduces the size/complexity of the primary Jenkinsfile and centralizes shared helper logic to support future de-duplication with downstream/release pipelines.

Changes:

  • Added a Bootstrap stage that checks out SCM, load()s helper scripts, and wires cross-helper dependencies.
  • Moved helper methods out of mlir/utils/jenkins/Jenkinsfile into six domain-focused helper files.
  • Updated Jenkinsfile call sites to use namespaced helper handles (e.g., ciLogic.*, nodeUtils.*, scmUtils.*, etc.).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
mlir/utils/jenkins/Jenkinsfile Removes inlined helpers, adds Bootstrap load/wiring, and updates call sites to namespaced helper objects.
mlir/utils/jenkins/helpers/scmUtils.groovy Extracts SCM-related helpers (git health check, robust checkout).
mlir/utils/jenkins/helpers/nodeUtils.groovy Extracts node health/Docker discovery logic and withHealthyNode() harness.
mlir/utils/jenkins/helpers/buildUtils.groovy Extracts build helpers for rocMLIR + CK/MIGraphX.
mlir/utils/jenkins/helpers/testUtils.groovy Extracts test/sweep/static-check/coverage helpers (includes the tail -n 1 fix).
mlir/utils/jenkins/helpers/reportUtils.groovy Extracts report publication and perfDB archival helpers.
mlir/utils/jenkins/helpers/ciLogic.groovy Extracts CI flow logic (labels/gating/splitting/failure classification/Teams notifications).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mlir/utils/jenkins/Jenkinsfile Outdated
Comment thread mlir/utils/jenkins/Jenkinsfile Outdated
Signed-off-by: bogdan-petkovic <bogdan.petkovic@htecgroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants