Jsonnet

Drone supports Jsonnet scripting as an alternate to yaml configurations. Jsonnet is a data templating language that extends Json syntax, adding constructs for generating, translating and refining data.

Jsonnet Language Specification

Jsonnet is intended for projects with complex configurations that benefit from advanced scripting capabilities and code re-use.

Usage

In order to use Jsonnet configuration files your system administrator must enable Jsonnet support for your Drone server.

You can use Jsonnet for an individual project by creating a .drone.jsonnet file in the root of your git repository. Then update your repository configuration file accordingly, from your repository settings screen.

Example

Here is an example script that returns a pipeline configuration. Please note the returned pipeline object uses the same structure as a pipeline defined in yaml.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
    "kind": "pipeline",
    "type": "docker",
    "name": "default",
    "steps": [
        {
            "name": "build",
            "image": "alpine",
            "commands:": [
                "echo hello world",
            ]
        }
    ]
}

Tooling

You can automatically convert your Jsonnet configuration file to yaml using the command line tools. This can be useful for local testing.

$ drone jsonnet --stdout

kind: pipeline
name: default

steps:
- name: build
  image: alpine
  commands: [ echo hello world ]