How to break a single command inside a `script` step on multiple lines

后端 未结 3 1513
旧巷少年郎
旧巷少年郎 2021-01-28 22:23

We have a project using Azure Pipeline, relying on azure-pipelines.yml file at the repo\'s root.

When implementing a script step, it is possibl

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-28 22:49

    At the moment, the only way we found for to break a single command on multiple line is using YAML folded style:

    - script: >
        echo
        'hello world'
    

    It is all about replacing | with >.

    Notes:

    • It is not possible to introduce extra indentation on the following lines! For example, trying to align all arguments given to a command would break the behaviour.
    • This style will replace newlines in the provided value with a simple white space. This means the script now can only contain a single command (maybe adding literal \n at the end of the line would actually introduce a linebreak in the string, but it feels backward compared to the usual approach of automatice linebreak unless an explicit continuation is added).

提交回复
热议问题