Updated 2 years ago by Admin

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 is intended for projects with complex configurations that benefit from advanced scripting capabilities and code re-use.


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.


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 "kind": "pipeline",
3 "type": "docker",
4 "name": "default",
5 "steps": [
6 {
7 "name": "build",
8 "image": "alpine",
9 "commands": [
10 "echo hello world",
11 ]
12 }
13 ]
14 }


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

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

Common Problems

The below error may indicate that Drone does not recognize your configuration as a jsonnet file. The most common root cause for this problem is when you forget to enable jsonnet in your Drone server settings.

yaml: line 1: mapping values are not allowed in this context

The second most common root cause for this issue is when you forget to rename your file with a jsonnet extension. Drone assumes configuration files are written in yaml unless you explicitly use the jsonnet file extension.

How did we do?