(english below)
In dieser Azure DevOps Nugget Blogserie werden alle zwei Wochen Features von Azure DevOps vorgestellt, die für Sie möglicherweise neu sind und die Arbeit mit Azure DevOps effizienter machen.
👨💻🛠️📜
Einige Tasks in YAML-Pipelines benötigen viele Argumente oder längeren Inline Code. Wer bereits den Command line oder PowerShell Task verwendet hat, kennt vielleicht die Möglichkeit über eine Pipe ‘|’ einen mehrzeiligen String einzugeben (siehe Screenshot, Zeile 8). In der Azure DevOps Dokumentation ist dies die einzige beschriebene Möglichkeit für sogenannte multi-line Strings (siehe Expressions – String). Doch die hilft uns hier nicht weiter, wenn viele Argumente oder längerer Code in einer einzelnen Zeile angegeben werden soll. Bei der Ausführung werden die einzelnen YAML-Zeilen über ein Newline verbunden und das wirft dann Fehler auf.
Glücklicherweise hält sich Microsoft an den YAML-Standard und man kann in dem Fall das Größer-Symbol ‘>’ verwenden (siehe Screenshot, Zeile 19). Nun werden bei der Ausführung die einzelnen YAML-Zeilen mit einem Leerzeichen verbunden. Neben diesen sogenannten Block Style Indicators (‘|’ und ‘>’) können zusätzlich noch Block Chomping Indicators verwendet werden (‘-‘ und ‘+’). Weitere Informationen hierzu unter: YAML Multiline – Find the right syntax for your YAML multiline strings
Every two weeks, this Azure DevOps Nugget blog series will highlight features of Azure DevOps that may be new to you and can make working with Azure DevOps more efficient.
👨💻🛠️📜
Some tasks in YAML pipelines require many arguments or long inline code. If you have already used the Command line or PowerShell task, you may be familiar with the option of entering a multi-line string via a pipe ‘|’ (see screenshot, line 8). In the Azure DevOps documentation, this is the only option described for multi-line strings (see Expressions – String). However, this does not help us if many arguments or longer code needs to be specified in a single line. During execution, the individual YAML lines are joined via a newline and this causes errors.
Fortunately, Microsoft adheres to the YAML standard and you can use the greater-than symbol ‘>’ instead (see screenshot, line 19). Now the individual YAML lines are joined with a space during execution. In addition to these so-called block style indicators (‘|’ and ‘>’), block chomping indicators can also be used (‘-‘ and ‘+’). Further information can be found here: YAML Multiline – Find the right syntax for your YAML multiline strings