Drone

Issues with using grep in Drone Pipeline

Hello,

I am having some issues with drone parsing a grep command in my pipeline. Essentially, I am using grep to pull a version number of one of my container images in order to promote the image from dev -> stage and eventually stage->prod. I am doing this through gcloud. My command to grab the image using gcloud syntax is:

gcloud container images list-tags <my-image-repository> --filter="tags:latest" --format="table[noheading](tags)" | grep -o '\bv\w*.*'

This command parses the correct information when I log directly into the docker container that I am using to execute this step, however, when I run it with Drone it appears to yank the \b from my grep command completely. I tested this with a pipeline by just running grep -o '\bv\w*.*' against a test.txt file that included a string v1.0.30841303 and the pipeline fails out with the last step showing the following:

+ grep -o 'v\w*.*' test.txt

Is there something I am doing wrong or is there something in Drone that would cause it to incorrectly parse the \b in my grep syntax?

Thank you!

you probably need to escape the value (e.g. \\b) so that yaml preserves the literal value, or you can do something like this:

steps:
- |
  gcloud container images list-tags <my-image-repository> --filter="tags:latest" --format="table[noheading](tags)" | grep -o '\bv\w*.*'

Drone is going to unmarhsal your commands to a []string variable and is then going to use these commands to generate a bash file. It will write the commands as-is and will not change them in any way. If the command is changing, it would have to be related to the yaml parsing (which is done by a third party library).