Skip to main content

Matrix Build

Run a job once for every combination of parameter values. This example expands two database values (Oracle, MySQL) and two operating-system values (Linux, Windows) into four builds whenever main is updated.

Configure the Job​

Edit .onedev-buildspec.yml and add a job named matrix.

  1. In Params & Triggers / Parameter Specs, define two required Text parameters: db and os.

    Matrix build parameters

  2. Add a Branch update trigger. Set Branches to main (or your branch name). For db, choose Use specified values and add Oracle and MySQL as separate values. For os, add Linux and Windows as separate values.

    Branch trigger with two values per parameter

  3. Add an Execute Commands step. To verify expansion, enable Run In Container, use image alpine:3.22, select POSIX Compatible Shell with shell sh, and enter:

    echo 'db=@param:db@ os=@param:os@'

    Command using both matrix parameters

This command only prints the chosen values. An os parameter does not select an agent's operating system, and a db parameter does not start a database. For actual cross-platform tests, configure suitable executors/agents and database services, and use the parameters in their selection or in your test commands.

Verify the Matrix​

Commit the specification to the configured branch. Open Builds, filter by "Job" is "matrix", and use Display Params to show db and os.

Verify four builds: Oracle/Linux, Oracle/Windows, MySQL/Linux, and MySQL/Windows. Open their logs to confirm each command received its corresponding values.

Four successful matrix combinations