I have a gitlab pipeline job that extracts the version number from a yaml file using yq tool and then exporting it as an environment variable. I am using mikefarah/yq:4.27.2 as a base image. the pipeline code is:
prepare-version:
image: mikefarah/yq:4.27.2
stage: prepare
script:
- ver=$(yq '.version' versions.yml)
- echo "version=${ver}" >> version.env
artifacts:
reports:
dotenv: version.env
The pipeline always fails on:
Using docker image sha256:cecdbf2efcf7240d3378dd188844b2b5805420eef692dfb98aa3a1b6d366ef5a for mikefarah/yq:4.27.2 with digest mikefarah/yq@sha256:856f7ab12c58608d422a742a4917e6998ad065d9d48a5b1cd69c3ce8fa80f3fa ...
Error: unknown shorthand flag: 'c' in -c
Usage:
yq eval [expression] [yaml_file1]... [flags]
Aliases:
eval, e
Examples:
# Reads field under the given path for each file
yq e '.a.b' f1.yml f2.yml
# Prints out the file
yq e sample.yaml
when using
yq '.version' versions.yml
locally with the same yq version everything works fine. But in the pipeline it fails. Any Ideas why this happens?