I’m trying to run a jq
command within one of the steps in my Drone pipeline. The command converts a JSON key/value pair (that is stored in an Env Var) to a plain ‘key=value’ string.
This works locally:
$ export TEST='{"foo": "bar"}'
$ jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <(echo ${TEST})
foo=bar
Within my drone pipeline I have the following (simplified for clarity):
---
kind: pipeline
type: kubernetes
name: matrix-1
platform:
os: linux
arch: amd64
steps:
- name: some_step
image: alpine:latest
commands:
- apk add jq
- jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <(echo $${TEST})
environment:
TEST:
from_secret: TEST
Unfortunately, this results in an error from Drone:
+ jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <(echo ${TEST})
/bin/sh: syntax error: unexpected "("
Clearly, there is something in that command that needs escaping for Drone to correctly process and execute the command.
Does anyone have any pointers?