Search code examples
azure-devopsyamlazure-pipelinesazure-storageazure-pipelines-yaml

Upload files to Azure Storage with Azure Devops Pipeline. cannot start job due to error: cannot scan the path \\?\D:\a\1\s\drop\editor-docs


I configured the Azure Devops Pipeline with a AzureFileCopy@5 / 6 task. I am trying to upload the Pipeline.Workspace/drop/folder name/ to the storage account.

The log confuses me : Uploading files from source path: 'D:\a\1\s\drop\editor-docs)' to storage account: storageaccountname

But in the next line I am receiving the error cannot start job due to error: cannot scan the path \?\D:\a\1\s\drop\editor-docs.

I also tried it with Powershell, but with Powershell I was not able to pass the path as a parameter and that causes the script failing with the error "the parameter ... is not recognized as a cmdlet".

How can I upload the artifact to Azure Storage? Changing the VM to Windows did not help for me.

Build.yml

jobs:
- job: 
  pool: 
    vmImage: 'ubuntu-latest'
  steps:
  - task: UseRubyVersion@0
    displayName: Use Ruby >= 2.4

  - task: CopyFiles@2
    displayName: Copy Folder Armtemplates
    inputs:
      SourceFolder: 'armtemplates'
      TargetFolder: '$(build.artifactstagingdirectory)/armtemplates'

  - task: CopyFiles@2
    displayName: Copy Folder Pipelines
    inputs:
      SourceFolder: 'pipelines'
      TargetFolder: '$(build.artifactstagingdirectory)/pipelines'

  - task: CopyFiles@2
    displayName: Copy Folder Scripts
    inputs:
      SourceFolder: 'scripts'
      TargetFolder: '$(build.artifactstagingdirectory)/scripts'

  - task: Bash@3
    inputs:
      filePath: '$(Build.SourcesDirectory)/scripts/InstallJekyll.sh'
      workingDirectory: '$(Build.SourcesDirectory)/editor-docs'
    displayName: Install Jekyll and bundler
      

  - task: CopyFiles@2
    displayName: Copy Folder _site
    inputs:
      SourceFolder: 'editor-docs/_site'
      TargetFolder: '$(build.artifactstagingdirectory)/editor-docs'


  - task: PublishPipelineArtifact@1
    displayName: 'Publish Artifact To Pipeline'
    inputs:
      targetPath: '$(Pipeline.Workspace)'
      artifact: 'drop'
      publishLocation: 'pipeline'

Deploy.yml I tried also : SourcePath: '$(Pipeline.Workspace)/drop/editor-docs/)'

jobs:
  - job: DeployStaticWebsite
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - download: current
      artifact: drop

    - task: AzureFileCopy@5
      displayName: Upload Web Files To Storage
      inputs:
        SourcePath: '$(Build.SourcesDirectory)/drop/editor-docs/)'
        azureSubscription: TestSubscriptionStorageAccount
        Destination: 'AzureBlob'
        storage: '$(StorageAccountNameStaticWebApp)'
        ContainerName: 'test'

Solution

  • error cannot start job due to error: cannot scan the path ?\D:\a\1\s\drop\editor-docs

    Based on the error message and the yaml sample, the cause of the issue is that you are using the wrong path variable in the AzureFileCopy task.

    The $(Build.SourcesDirectory) will point to the path: D:\a\1\s. But the artifacts will be download to $(Pipeline.Workspace) (D:\a\1).

    To solve this issue, you need to use the path $(Pipeline.Workspace)/drop/editor-docs/ in the Azurefilecopy task.

    For example:

    - task: AzureFileCopy@5
      displayName: Upload Web Files To Storage
      inputs:
        SourcePath: '$(Pipeline.Workspace)/drop/editor-docs/'
        azureSubscription: TestSubscriptionStorageAccount
        Destination: 'AzureBlob'
        storage: '$(StorageAccountNameStaticWebApp)'
        ContainerName: 'test'
    

    On the other hand, if the build and deploy pipeline are two independent pipelines, you need to specify specific build information in the download artifacts task.

    For example:

    jobs:
      - job: DeployStaticWebsite
        pool:
          vmImage: 'ubuntu-latest'
        steps:
        - task: DownloadPipelineArtifact@2
          inputs:
            buildType: 'specific'
            project: 'projectname'
            definition: 'definitionname'
            buildVersionToDownload: 'latest'
            artifactName: 'drop'
            targetPath: '$(Pipeline.Workspace)'
    
        - task: AzureFileCopy@5
          displayName: Upload Web Files To Storage
          inputs:
            SourcePath: '$(Build.SourcesDirectory)/drop/editor-docs/'
            azureSubscription: TestSubscriptionStorageAccount
            Destination: 'AzureBlob'
            storage: '$(StorageAccountNameStaticWebApp)'
            ContainerName: 'test'
    

    For more detailed info, you can refer to the doc: Use predefined variables and DownloadPipelineArtifact@2 - Download Pipeline Artifacts v2 task