0
0
Jenkinsdevops~10 mins

Matrix builds for multi-platform in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Matrix builds for multi-platform
Start Build
Define Matrix Axes
Generate Combinations
Run Each Combination
Collect Results
Report Success/Failure
End
The build starts by defining platforms and configurations, then runs all combinations in parallel, collects results, and reports the final status.
Execution Sample
Jenkins
pipeline {
  agent any
  stages {
    matrix {
      axes {
        axis {
          name 'PLATFORM'
          values 'linux', 'windows'
        }
      }
      stages {
        stage('Build') {
          steps {
            echo "Building on ${PLATFORM}"
          }
        }
      }
    }
  }
}
This Jenkins pipeline runs a build stage on both Linux and Windows platforms using a matrix.
Process Table
StepMatrix AxisCombinationActionOutput
1PLATFORMlinuxStart build for linuxEcho: Building on linux
2PLATFORMwindowsStart build for windowsEcho: Building on windows
3All combinationslinux, windowsCollect resultsBoth builds completed successfully
4Final-Report statusBuild success if all passed
💡 All matrix combinations completed, build ends with aggregated result
Status Tracker
VariableStartAfter 1After 2Final
PLATFORM-linuxwindows-
Build Statuspendingsuccess (linux)success (windows)success
Key Moments - 3 Insights
Why does Jenkins run multiple builds in parallel here?
Because the matrix defines multiple platforms (linux, windows), Jenkins runs each combination separately and in parallel as shown in execution_table rows 1 and 2.
How does Jenkins know when the entire matrix build is done?
Jenkins waits for all combinations to finish (rows 1 and 2), then collects results (row 3) before reporting final status (row 4).
What happens if one platform build fails?
The final report (row 4) will mark the overall build as failed, even if other platforms succeeded.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the PLATFORM value at step 2?
Awindows
BmacOS
Clinux
Dandroid
💡 Hint
Check the 'Combination' column at step 2 in the execution_table.
At which step does Jenkins collect results from all builds?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look for the 'Collect results' action in the execution_table.
If a new platform 'macOS' is added to the matrix, what changes in the execution_table?
AStep 4 will be removed
BAn extra row for macOS build will appear between steps 2 and 3
CStep 1 will run twice
DNo changes needed
💡 Hint
Adding a platform adds a new combination build step before collecting results.
Concept Snapshot
Matrix builds run multiple configurations in parallel.
Define axes like PLATFORM with values (linux, windows).
Jenkins runs each combination as a separate build.
Results are collected and aggregated at the end.
Useful for testing multi-platform compatibility.
Full Transcript
Matrix builds in Jenkins allow running the same build on multiple platforms or configurations automatically. The process starts by defining axes such as PLATFORM with values like linux and windows. Jenkins generates all combinations and runs each build in parallel. After all builds finish, Jenkins collects the results and reports the overall status. This helps test software on different environments efficiently.