How can I add arguments with values from a variable to command line?

55 Views Asked by At

I'm trying to run Testim job in Gitlab CI with some hardcoded arguments and some arguments taken from Gitlab CI pipeline's UI. Testim runner requires multiple labels should be passed each in a separate argument: --label "Label1" --label "Label 2"....

TESTIM_DOCKER=testim/docker-cli
TESTIM_TOKEN=some_token
TESTIM_PROJECT=some_project
GRID_NAME=some_grid

# This goes from UI:
TESTIM_LABELS="Tryout,Integration,Edit Entity"

# A dedicated script parses those labels:
LABELS=$(./scripts/misc/parse_testim_labels.sh $TESTIM_LABELS)

# Here what inside LABELS variable
$ echo $LABELS
--label 'tryout' --label 'Integration' --label 'Edit Entity'

Then I'm trying to execute the command below, so the idea is instead echo $LABELS should appear --label 'tryout' --label 'Integration' --label 'Edit Entity' but this does not work:

docker run --rm -v "$(pwd)":/opt/testim-runner $TESTIM_DOCKER \
--token $TESTIM_TOKEN \
--project $TESTIM_PROJECT \
echo $LABELS \
--grid $GRID_NAME \
--base-url $TESTIM_BASE_URL \
--report-file /opt/testim-runner/testim-report.xml

What is a correct way to insert those arguments to that command line?

UPD1: I wrapped echo $LABELS into backticks and executing set -xv docker run... got this:

set -xv docker run --rm -v /Users/miric/code/main:/opt/testim-runner testim/docker-cli --token some_token --project some_project --label \''tryout'\' --label \''Integration'\' --label \''Edit' 'Entity'\' --grid some_grid --base-url --report-file /opt/testim-runner/testim-report.xml
0

There are 0 best solutions below