Jsonnet library for generating Drone CI configuration file.
jb install github.com/crdsonnet/drone-libsonnet@master
// drone.jsonnet
local drone = import 'github.com/crdsonnet/drone-libsonnet/main.libsonnet';
local pipeline = drone.pipeline.docker;
local step = drone.pipeline.docker.step;
local pipelines = {
build_pipeline:
pipeline.new('build pipeline')
+ pipeline.withSteps([
step.new('build', image='golang:1.19')
+ step.withCommands(['go build ./...']),
step.new('test', image='golang:1.19')
+ step.withCommands(['go test ./...']),
]),
};
drone.render.getDroneObjects(pipelines)
The suggested jsonnet version is go-jsonnet, you can get it here:
drone jsonnet --stream \
--format \
--source <(jsonnet -J vendor/ drone.jsonnet) \
--target .drone.yamlOriginally the intention was to render YAML with
std.manifestYamlStream(), however at Grafana Labs we noticed that this function suffers from performance issues (taking 16 seconds to render a 23K LoC YAML). Its much faster to render the drone pipeline into json withdrone.render.getDroneObjects()and use thedronecli tooling to do the YAML conversion. Alternativelyjsonnet -ycan be used, which delivers a valid YAML stream (json as valid YAML) but it might not look as nice.