Search code examples
azureazure-devopsyamlazure-pipelinesazure-pipelines-yaml

Escaping Whitespace in YAML


I am creating the YAML file for an Azure Pipeline which will automatically publish and deploy the ARM template of an Azure Data Factory on commit.

Unfortunately, the repo for the project involves whitespace, and I have no control over renaming it.

I have the code for this task:

- task: Npm@1
  inputs:
    command: 'custom'
    workingDir: '$(Build.Repository.LocalPath)/Solutions/My Code Repo/Migration/MyDataFactory'
    customCommand: 'run build export $(Build.Repository.LocalPath)/Solutions/My Code Repo/Migration/MyDataFactory /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.DataFactory/factories/my-data-dactory "ArmTemplate"'
  displayName: 'Validate and Generate ARM template'

I would like to be able to escape the whitespace in "My Code Repo", as the rest of the whitespace is used by the command.


Solution

  • You can try to use the double quotes (" ") to surround the arguments which contain the whitespace.

    - task: Npm@1
      inputs:
        command: 'custom'
        workingDir: '$(Build.Repository.LocalPath)/Solutions/My Code Repo/Migration/MyDataFactory'
        customCommand: 'run build export "$(Build.Repository.LocalPath)/Solutions/My Code Repo/Migration/MyDataFactory" /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.DataFactory/factories/my-data-dactory "ArmTemplate"'
      displayName: 'Validate and Generate ARM template'