docs icon indicating copy to clipboard operation
docs copied to clipboard

Long one line command can be divided into more lines with '>-'

Open mimimalizam opened this issue 6 years ago • 1 comments
trafficstars

One user recently asked for a way to divide a long one-line command and it can be achieved by writing the line in the folded style (>) and by stripping the line break in the yaml file (-). To do this, we can start the command with line containing only >- and write the command in more lines below it.

https://yaml.org/spec/1.2/spec.html#Block

Example yaml:

version: "v1.0"
name: First pipeline example
agent:
  machine:
    type: e1-standard-2
    os_image: ubuntu1804

blocks:
  - name: "First block"
    task:
      jobs:
      - name: Divide one line command
        commands:
          - >- 
            sudo apt-get install -y
            htop
            git
            curl
            wget

mimimalizam avatar Feb 25 '19 14:02 mimimalizam

I recommend the example to contain a multiline Bash if statement. I was blown away when I saw it's possible to write it like that in yml. :)

markoa avatar Mar 20 '19 10:03 markoa