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.
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.
2 "kind": "pipeline",
3 "type": "docker",
4 "name": "default",
5 "steps": [
7 "name": "build",
8 "image": "alpine",
9 "commands": [
10 "echo hello world",
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
- name: build
commands: [ echo hello world ]
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.