azure pipeline multiline script
Asked Answered
I

2

20
steps:

- script: |
    echo "good"
    echo "nice"

This doesn't work. It prints 'good' successfully, but doesn't print nice and shows echo "nice" so the final output is

good echo 'nice'

I tried to remove | after the script: but still no luck. Any idea? I am running this on ubuntu machine.

Illation answered 25/2, 2020 at 9:36 Comment(2)
This issue can not be reproduced. You can provide the complete YAML code see if we can help solve the issue if it is possible. Or, please try to add a Bash or Command line task and add inline script. Also, make sure the | is there since the script can not be recognized as two lines without it.Juncaceous
This problem has been resolved? since we didn't get more information. You can share the solution if it is possible. Thanks!Juncaceous
I
26

I get the desired output. This is how my pipeline looks like:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: |
    echo "good"
    echo "nice"

Output:

enter image description here


Answer to the question in the comments:

This is how I pass multiple parameters to the ARM deployment task:

steps:
  - task: AzureResourceManagerTemplateDeployment@3
    displayName: "MyDeployment"
    inputs:
      deploymentScope: "Resource Group"
      ConnectedServiceName: ${{ parameters.serviceConnection }}
      action: "Create Or Update Resource Group"
      resourceGroupName: "$(resourceGroupName)"
      location: "$(location)"
      templateLocation: "Linked artifact"
      csmFile: "$(Pipeline.Workspace)/drop/azuredeploy.json"
      overrideParameters: "
        -eventGridTopicName myEventGridName
        -appServicePlanName myAppServicePlan"
      deploymentMode: "Incremental"
Infantryman answered 25/2, 2020 at 9:49 Comment(4)
How do you use mulitline when fx. providing override parameters in an ARM deployment task? overrideParameters: >- '-environment_name ${{ parameters.environmentName }} -vnetAddressPrefix ${{ parameters.vnetAddressPrefix }} -subnet1Prefix ${{ parameters.subnet1Prefix }} This doesn't seem to work I also tried with overrideParameters: |Leacock
@OliverNilsen I edited my answer and included a sample how I pass multiple parameters (not with mulitline)Infantryman
I have figured it out. Posted an answer to my own question here: #63228854Leacock
@MartinBrandl It seems to me that the answer to the comment is not directly related to the original question.Kersey
D
0

I've found that this can unexpectedly occur when executing .bat or .cmd files such as npm or npx. The solution is to execute these with the call command:

steps:
- script: |
    call npx playwright install-deps
    call npx playwright install chromium
Driskell answered 30/5, 2024 at 16:13 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.