Can you import your own jsonnet libraries?

can I import a libsonet file from my repository?

the drone-jsonnet-config extension can import libsonet files from your repository, however, the embedded jsonnet feature cannot import.

1 Like

Hey, I’m sorry for posting it here but maybe you could help.
I’m switching from built-in jsonnet to external extension by setting
DRONE_JSONNET_ENABLED = false
and
DRONE_CONVERT_PLUGIN_ENDPOINT = xxx
DRONE_CONVERT_PLUGIN_SECRET = xxx
DRONE_CONVERT_PLUGIN_EXTENSION = “.jsonnet”

But yet I bump into ‘yaml: line 1: mapping values are not allowed in this context’ like Drone is treating my pipeline file as yaml

Drone has multiple extension types. The jsonnet extension is a Configuration Extension and needs to be configured with different environment variables (see Configuration Extension | Drone). The jsonnet extension was created before the existence of Conversion Extensions which is what one would use if they were creating a jsonnet extension today.

I am not sure if proper configuration will solve the specific error message. If this does not solve the error, you will need to find a way to gather more data since this is not enough detail to diagnose the problem (sample jsonnet file? sample of what is returned from the extension?). You will not be able to use curl to interact with the extension because the extension requires an http-signature, however, you can use the command line tools to hit the extension endpoint directly and test it out (see below). You should also expect to download the jsonnet extension code and compile from source / debug as needed.

% drone plugins config get --help
NAME:
   drone plugins config get - get the pipeline configuration

USAGE:
   drone plugins config get [command options] [repo/name]

OPTIONS:
   --ref value              git reference (default: "refs/heads/master")
   --source value           source branch (default: "master")
   --target value           target branch (default: "master")
   --before value           commit sha before the change
   --after value            commit sha after the change
   --path value             configuration file path (default: ".drone.jsonnet")
   --endpoint value         plugin endpoint [$DRONE_YAML_ENDPOINT]
   --secret value           plugin secret [$DRONE_YAML_SECRET]
   --ssl-skip-verify value  plugin ssl verification disabled [$DRONE_YAML_SKIP_VERIFY]

Thanks a lot!

I’ve tried to switch to DRONE_YAML_ENDPOINT and DRONE_YAML_SECRET.
No luck though.

Well it might be a problem with my extension setup since
drone plugins config get --path "drone.jsonnet" --target "feature/xxx" --secret "xxx" --endpoint "https://drone-jsonnet.xxx/" xxx/terraform
gives me empty output and I can’t see any new log records on extension side (there are other records created on my lb healthchecks)

Is there some option for cli tool to produce verbose logs? I haven’t found any in the help.

Some details:

  • I am running a docker version of extension (drone/drone-jsonnet) and I have PLUGIN_DEBUG set to true. I cannot get a sample of what is returned from the extension because of the above
  • My pipeline is being successfully interpreted and executed by built-in jsonnet extension (DRONE_JSONNET_ENABLED=true) so it’s a valid jsonnet file.

You probably need to clone and build from source so that you can more easily debug the code