[solved] Jsonnet multiple pipelines

Hi,

could someone help me how to have multiple pipelines using jsonnet? I could not figure it out, either I have one, or I get a “kind” missing message.

Thanks a lot.

example at https://docs.drone.io/pipeline/docker/examples/languages/golang/#test-multiple-versions

This did not work for me, I’m always getting the following error (using drone-cli 1.2.0):

2019/11/15 13:47:51 yaml: unmarshal errors:
line 1: cannot unmarshal !!seq into yaml.RawResource

What did I do wrong? I"m using the code as given in the example.

you need to use the --stream flag when you are processing a stream of multiple yaml files.

3 Likes

Had the same issue. Tried debugging by incrementally paring down my .jsonnet file until it had virtually nothing and I still kept getting the same error. Then on a whim, I tried transpiling the jsonnet to yml locally using drone jsonnet --stream, changed the config file back to .drone.yml and pushed up the newly transpiled .yml file and it worked as expected. Not ideal but usable workaround.

Edit: Hopefully this debugging flow can point the way toward figuring out the source of the problem?

Am I right that multiple pipelines are not supported with server jsonnet to yaml conversion support (DRONE_JSONNET_ENABLED)?

nope, multi-pipeline jsonnet files are fully supported

Could you help me, I use.drone.jsonnet and convert to .drone.yml every time I change it. Both files in git and drone works fine.
Tried enabling native support and got this error:

invalid or missing step name

What I did:

  1. Self hosted drone v1.10.1
  2. Server flag DRONE_JSONNET_ENABLED=true
  3. Set file in UI to .drone.jsonnet
  4. Removed generated .drone.yml
  5. Got this error

I clicked the link and I see two stages (arm and arm64) in the Drone user interface which means Drone successfully parsed your jsonnet file. If it was a problem with jsonnet parsing, or lacking support for multiple stages, we would not see those two stages in the user interface.

Instead, the error message tells me that the jsonnet generates an invalid yaml, where at least one of your pipeline steps does not have a name.

EDIT: I used the jsonnet command line tools to execute your jsonnet file, and I noticed you have empty steps with no data (see below). These empty steps are the root cause of the error, and need to be removed.

      {},
      {},
      {
        "commands": [
          "VERSION=$(cat version)",
          "PACKAGE=$(cat package.name)",
          "pip2 install -r dev_requirements.txt",
          "syncloud-upload.sh home-assistant $DRONE_BRANCH $VERSION $PACKAGE"
        ],
        "environment": {
          "AWS_ACCESS_KEY_ID": {
            "from_secret": "AWS_ACCESS_KEY_ID"
          },
          "AWS_SECRET_ACCESS_KEY": {
            "from_secret": "AWS_SECRET_ACCESS_KEY"
          }
        },
        "image": "syncloud/build-deps-arm:2021.4.1",
        "name": "upload"
      },