Task: Support for multiline cmds

Created on 11 Dec 2019  路  2Comments  路  Source: go-task/task

Like in CircleCI config file I'd like to be able to define cmds over multiple lines

Here is an example how this looks in a CircleCI config yaml:

steps:
        - configure-python-version
        - checkout
        - run:
            name: EXECUTE ROBOT COMMAND
            command: |
                cd tests
                robot --include tagname \
                      --exclude TODO -e future -e obsolete -e libtest \
                      --console dotted \
                      --loglevel TRACE \
                      --noncritical not-ready \
                      --outputdir results/testsuite-name \
                      --name testsuite \
                      robot/test-suite-folder/

With tasks something like this fails with error documented below

# example Taskfile.yml
tasks:
    test_all:
      desc: RUN ALL ROBOT TESTS
      cmds: |
        robot -e future -e circleci -e TODO -e obsolete -d results -L TRACE \
              --noncritical not-ready robot/QUERY_SERVICE_TESTS

error

yaml: unmarshal errors:
  line 78: cannot unmarshal !!str `robot -...` into []*taskfile.Cmd
question

Most helpful comment

Hi @testautomation,

You got this error because on v2 (and master), cmds is an array and so you can't declare it as a string. The following would work:

tasks:
  test-all:
    cmds:
      - |
        echo 'You command here'

On the (still unreleased) v3, we have alternative tasks syntaxes so you snippet would work. You can check the WIP documentation here.

All 2 comments

Hi @testautomation,

You got this error because on v2 (and master), cmds is an array and so you can't declare it as a string. The following would work:

tasks:
  test-all:
    cmds:
      - |
        echo 'You command here'

On the (still unreleased) v3, we have alternative tasks syntaxes so you snippet would work. You can check the WIP documentation here.

@andreynering thank you!

Was this page helpful?
0 / 5 - 0 ratings