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

后端 未结 3 1462
旧巷少年郎
旧巷少年郎 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:54

    You didn't specify your agent OS so I tested on both windows-latest and ubuntu-latest. Note that the script task runs a bit differently on these 2 environments. On Windows, it uses cmd.exe. On Ubuntu, it uses bash. Therefore, you have to use the correct syntax.

    On Windows:

    pool:
      vmImage: 'windows-latest'
    
    steps:
    - script: |
        mkdir ^
        test ^
        -p ^
        -v
    

    On Ubuntu:

    pool:
      vmImage: 'ubuntu-latest'
    
    steps:
    - script: |
        mkdir \
        test \
        -p \
        -v
    

    Those two files above work on my Azure DevOps.

提交回复
热议问题