Drone

Porting matrix builds to 1.0 multi-machine pipelines

Please note that matrix syntax have been deprecated in 1.0.0 in favor of multi-machine pipelines. You can still perform matrix builds, however, the syntax has changed to enable many more powerful use cases (fan-in, fan-out, dag, etc).

Example matrix build in 0.8

pipeline:
  build:
    image: golang:${golang}
    commands: [ go build, go test ]
matrix:
  golang: [ 1.0, 1.1 ]

Example matrix build in 1.0

---
kind: pipeline
name: golang-1-0

steps:
- name: build
  image: golang:1.0
  commands:
  - go build
  - go test
---
kind: pipeline
name: golang-1-1

steps:
- name: build
  image: golang:1.1
  commands:
  - go build
  - go test

Example matrix build in 1.0 using jsonnet:

local Pipeline(version) = {
  kind: "pipeline",
  steps: [
    {
      name: "build",
      image: "golang:"+version,
      commands: [
        "go build",
        "go test",
      ]
    }
  ]
};

[
  Pipeline("1.0"),
  Pipeline("1,1")
]

The above jsonnet document can be used to generate your yaml configuration file. This file is to be committed to your git repository. You can download the jsonnet command line utility from here or you can use the Drone command line utility.

drone jsonnet --stream`

Automated Jsonnet to Yaml

Drone can natively parse jsonnet files if you enable the below configuration parameter. Note that includes and imports are not supported. You will also need to rename your configuration file to .drone.jsonnet and update your repository settings in the user interface accordingly.

DRONE_JSONNET_ENABLED=true

Fallback to 0.8 Yaml

Please note that Drone 1.0 is almost entirely backward compatible with the 0.8 yaml, including the matrix syntax. Drone will automatically handle the conversion at runtime if it detects the yaml is using the old syntax.

1 Like