Drone ECR jsonnet error unexpected type array, expected number

I’m trying to deploy with the ECR plugin and my jsonnet file looks like:

local push_to_ecr(branch) = {
  name: 'build and publish to ECR_' + branch,
  image: 'plugins/docker',
  settings: {
    repo: 'bar',
    registry: '<some-account-id>.dkr.ecr.us-east-1.amazonaws.com',
    region: 'us-east-1',
    tags: +(
      if branch == 'master' then ['someprefix_${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:8}', 'latest-manual']
      else ['someprefix_${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:8}']
    ),
  },
  when: {
    branch: [branch],
  },
};

{
  kind: 'pipeline',
  name: 'default',
  steps: [
    push_to_ecr('develop'),
    push_to_ecr('master'),
  ]
}

The error I’m getting is:

RUNTIME ERROR: Unexpected type array, expected number .drone.jsonnet:(8:11)-(11:6) object <anonymous> During manifestation

What i’ve tried is:

  • jsonnetfmt -i .drone.jsonnet
  • drone jsonnet --stdout

Looked fine. It’s something within the tags conditional part, but I’m running out of ideas :frowning: Any help is appreciated.

Update:

  1. The image should be: image: 'plugins/ecr',
  2. If I use the yml file as a result of drone jsonnet command, the pipeline is running fine, but if I use the jsonnet file instead, I got the same error.

Hello there,

As the yaml file generated as result of drone jsonnet command works fine here, request you to kindly confirm if you have enabled jsonnet(https://docs.drone.io/server/reference/drone-jsonnet-enabled/) in your Drone server settings.

If not, request you to kindly enable it and then retry. Share with us the results then.

Thanks!!

Hi @csgit. Thanks for reaching out! I’ve enabled the variable already, and I’ve setup the pipeline to deploy from .drone.jsonnet file. I’m using Drone server version 1.10.1 though.

I’ve commented out the tags conditional part, and add something like this:

/* tags: +(
     if branch == 'master' then ['someprefix_${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:8}', 'latest-manual']
     else ['someprefix_${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:8}']
), */
    tags: [
      'someprefix_${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:8}'
    ],

This works. Please let me know what you think.

Thanks in advance!