woodpecker/docs/versioned_docs/version-2.1/20-usage/30-matrix-workflows.md

144 lines
2.4 KiB
Markdown
Raw Normal View History

2023-12-26 18:49:12 +00:00
# Matrix workflows
Woodpecker has integrated support for matrix workflows. Woodpecker executes a separate workflow for each combination in the matrix, allowing you to build and test against multiple configurations.
Example matrix definition:
```yaml
matrix:
GO_VERSION:
- 1.4
- 1.3
REDIS_VERSION:
- 2.6
- 2.8
- 3.0
```
Example matrix definition containing only specific combinations:
```yaml
matrix:
include:
- GO_VERSION: 1.4
REDIS_VERSION: 2.8
- GO_VERSION: 1.5
REDIS_VERSION: 2.8
- GO_VERSION: 1.6
REDIS_VERSION: 3.0
```
## Interpolation
Matrix variables are interpolated in the YAML using the `${VARIABLE}` syntax, before the YAML is parsed. This is an example YAML file before interpolating matrix parameters:
```yaml
matrix:
GO_VERSION:
- 1.4
- 1.3
DATABASE:
- mysql:8
- mysql:5
- mariadb:10.1
steps:
build:
image: golang:${GO_VERSION}
commands:
- go get
- go build
- go test
services:
database:
image: ${DATABASE}
```
Example YAML file after injecting the matrix parameters:
```diff
steps:
build:
- image: golang:${GO_VERSION}
+ image: golang:1.4
commands:
- go get
- go build
- go test
+ environment:
+ - GO_VERSION=1.4
+ - DATABASE=mysql:8
services:
database:
- image: ${DATABASE}
+ image: mysql:8
```
## Examples
### Example matrix pipeline based on Docker image tag
```yaml
matrix:
TAG:
- 1.7
- 1.8
- latest
steps:
build:
image: golang:${TAG}
commands:
- go build
- go test
```
### Example matrix pipeline based on container image
```yaml
matrix:
IMAGE:
- golang:1.7
- golang:1.8
- golang:latest
steps:
build:
image: ${IMAGE}
commands:
- go build
- go test
```
### Example matrix pipeline using multiple platforms
```yaml
matrix:
platform:
- linux/amd64
- linux/arm64
labels:
platform: ${platform}
steps:
test:
image: alpine
commands:
- echo "I am running on ${platform}"
test-arm-only:
image: alpine
commands:
- echo "I am running on ${platform}"
- echo "Arm is cool!"
when:
platform: linux/arm*
```
:::note
Bump follow-redirects and fix broken anchors (#3488) - Bump `follow-redirects` to fix sec scan - Remove archived plugin `Chart releaser` - Fix broken anchors ``` Exhaustive list of all broken anchors found: - Broken anchor on source page path = /docs/0.15/administration/agent-config: -> linking to /docs/0.15/usage/pipeline-syntax#step-when---conditional-execution - Broken anchor on source page path = /docs/0.15/development/docs: -> linking to /docs/0.15/development/getting-started#nodejs--yarn - Broken anchor on source page path = /docs/0.15/development/ui: -> linking to /docs/0.15/development/getting-started#nodejs--yarn -> linking to /docs/0.15/development/getting-started#debugging - Broken anchor on source page path = /docs/1.0/development/ui: -> linking to /docs/1.0/development/getting-started#debugging - Broken anchor on source page path = /docs/2.0/administration/agent-config: -> linking to /docs/2.0/administration/backends/kubernetes#configuration - Broken anchor on source page path = /docs/2.0/administration/server-config: -> linking to forges/github#configuration (resolved as: /docs/2.0/administration/forges/github#configuration) - Broken anchor on source page path = /docs/2.0/development/ui: -> linking to /docs/2.0/development/getting-started#debugging - Broken anchor on source page path = /docs/2.0/usage/matrix-workflows: -> linking to /docs/2.0/administration/backends/kubernetes#nodeSelector - Broken anchor on source page path = /docs/2.1/administration/agent-config: -> linking to /docs/2.1/administration/backends/kubernetes#configuration - Broken anchor on source page path = /docs/2.1/development/ui: -> linking to /docs/2.1/development/getting-started#debugging - Broken anchor on source page path = /docs/2.1/usage/matrix-workflows: -> linking to /docs/2.1/administration/backends/kubernetes#nodeSelector - Broken anchor on source page path = /docs/2.2/administration/agent-config: -> linking to /docs/2.2/administration/backends/local#further-configuration - Broken anchor on source page path = /docs/2.2/development/ui: -> linking to /docs/2.2/development/getting-started#debugging - Broken anchor on source page path = /docs/2.2/usage/matrix-workflows: -> linking to /docs/2.2/administration/backends/kubernetes#nodeSelector - Broken anchor on source page path = /docs/next/administration/agent-config: -> linking to /docs/next/administration/backends/local#further-configuration - Broken anchor on source page path = /docs/next/development/ui: -> linking to /docs/next/development/getting-started#debugging - Broken anchor on source page path = /docs/next/usage/matrix-workflows: -> linking to /docs/next/administration/backends/kubernetes#nodeSelector - Broken anchor on source page path = /docs/next/usage/plugins/creating-plugins: -> linking to /docs/next/usage/secrets#use-secrets-in-settings - Broken anchor on source page path = /docs/administration/agent-config: -> linking to /docs/administration/backends/local#further-configuration - Broken anchor on source page path = /docs/development/ui: -> linking to /docs/development/getting-started#debugging - Broken anchor on source page path = /docs/usage/matrix-workflows: -> linking to /docs/administration/backends/kubernetes#nodeSelector ```
2024-03-15 10:56:31 +00:00
If you want to control the architecture of a pipeline on a Kubernetes runner, see [the nodeSelector documentation of the Kubernetes backend](../30-administration/22-backends/40-kubernetes.md#nodeselector).
2023-12-26 18:49:12 +00:00
:::