Search code examples
azure-pipelinesazure-cliazure-pipelines-yaml

Azure CLI task inline script for a single command on multiple lines for visibility


As the title said, I'm looking for a way to display a single command in an Azure CLI inline script on multiple lines. It is purely for visibility since I happen to have a lot of parameters for the script I'm using.

It is working fine as is but just wondering if it can be improved for future developers.


I am aware that adding a pipe "|" at the start is used to have multiple lines like this :

- task: AzureCLI@2
  inputs:
    ## other info
    inlineScript: |
      cd $(Pipeline.Workspace)/scripts/apimdevportal/
      node .\migrate.js --sourceSubscriptionId ${{ parameters.apimSourceSubscriptionId }} --sourceResourceGroupName ${{ parameters.apimSourceRgName }} --sourceEnvironmentName ${{ parameters.apimSourceRgName }} --theListGoesOn

The issue, if I may say, is the fact that my migrate.js script needs a lot of parameters and I wanted to see them all in one go instead of scrolling horizontally to see the last parameter.

What I want to achieve :

- task: AzureCLI@2
  inputs:
    ## other info
    inlineScript: |
      cd $(Pipeline.Workspace)/scripts/apimdevportal/
      node .\migrate.js --sourceSubscriptionId ${{ parameters.apimSourceSubscriptionId }} 
                        --sourceResourceGroupName ${{ parameters.apimSourceRgName }} 
                        --sourceEnvironmentName ${{ parameters.apimSourceRgName }} 
                        --theListGoesOn

I though of using |, ^, ~ at the end of each line but my pipeline always returns an error.

Again, it is only for a better visibility for the developer.

Thanks for your help !


Solution

  • You need to use ` e.g.

    - task: AzureCLI@2
      inputs:
        ## other info
        inlineScript: |
          cd $(Pipeline.Workspace)/scripts/apimdevportal/
          node .\migrate.js --sourceSubscriptionId ${{ parameters.apimSourceSubscriptionId }} `
                            --sourceResourceGroupName ${{ parameters.apimSourceRgName }} `
                            --sourceEnvironmentName ${{ parameters.apimSourceRgName }} `
                            --theListGoesOn