skip to Main Content

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.

2

Answers


  1. You shouldn’t need to do any escaping. Assuming you want to run npm run-script build, this should work for you:

    - task: Npm@1
      inputs:
        command: 'custom'
        workingDir: "$(Build.Repository.LocalPath)/Solutions/My Code Repo/Migration/MyDataFactory"
        customCommand: 'run-script build . /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.DataFactory/factories/my-data-dactory "ArmTemplate"'
      displayName: 'Validate and Generate ARM template'
    
    Login or Signup to reply.
  2. 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'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search