Tuesday 26 December 2017

yaml - How to break up command in CircleCI yml to multiple lines?





I have a CircleCI configuration file that looks like
so:




# Customize test
commands
test:
override:
- docker run -e VAR1=$VAR! -e
VAR2=$VAR2 -e $VAR3-$VAR3 --entrypoint python my_image:latest -m unittest discover -v -s
test


How can I break
up the docker run command into multiple lines
like:



docker run \
-e
VAR1=$VAR! \

-e VAR2=$VAR2 \
-e $VAR3-$VAR3
\
--entrypoint python my_image:latest \
-m unittest discover -v -s
test


I've tried using
the | operator for yaml, but CircleCI was unable to parse
because it expects override to be a
list.



# Customize test
commands
test:

override: |
docker run
\
-e VAR1=$VAR! \
-e VAR2=$VAR2 \
-e $VAR3-$VAR3
\
--entrypoint python my_image:latest \
-m unittest discover -v -s
test

class="post-text" itemprop="text">
class="normal">Answer



Using this
href="https://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines">answer
which details the various ways to break up a string over multiple lines in yaml, I was
able to deduce a solution which works
nicely.




Note the use of the
>- operator in the override
section.



test:

override:
- >-
docker run
-e VAR1=$VAR!

-e VAR2=$VAR2
-e $VAR3-$VAR3

--entrypoint python
my_image:latest
-m unittest discover -v -s
test


This generates a
nice single-line command
of:



docker run -e VAR1=$VAR! -e
VAR2=$VAR2 -e $VAR3-$VAR3 --entrypoint python my_image:latest -m unittest discover -v -s
test

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...