kiran jan
kiran jan

Reputation: 77

Azure DevOps artifact directory issue

When I try to run a Powershell script using Azure DevOps pipeline, I'm getting an error "ENOENT: no such file or directory, stat '/azp/agent/_work/1/a/repo1/folder1/Powershell-newscript.ps1

Log file suggest that the file is located at: /azp/agent/_work/1/s/repo1/folder1/Powershell-newscript.ps1

How do I move this file from 's' to 'a'? /azp/agent/_work/1/s to /azp/agent/_work/1/a

   - checkout: self
   - checkout: IAC

      - task: CopyFiles@2
        inputs:
          targetFolder: '$(Build.ArtifactStagingDirectory)'

      - task: PublishBuildArtifacts@1
        displayName: 'Building Artifact now'
        inputs:
          pathToPublish: '$(Build.ArtifactStagingDirectory)'
          artifactName: 'drop-self'

   steps:
      - task: DownloadBuildArtifacts@0
        inputs:
          artifactName: 'drop-self'
          downloadPath: '$(System.ArtifactsDirectory)'
     

      - task: AzurePowerShell@5
        inputs:
          azureSubscription: ${{parameters.subName}}
          ScriptType: 'FilePath'
          ScriptPath: '$(System.ArtifactsDirectory)/repo1/folder1/Powershell-newscript.ps1'
          azurePowerShellVersion: 'LatestVersion'

Could you please help? Thanks!

Upvotes: 1

Views: 518

Answers (1)

Nadine Raiss
Nadine Raiss

Reputation: 641

If you want to use your Artifacts from a specific build, you need to reference the file path in the release pipeline as follows: '$(Pipeline.Workspace)/{DefinedNameofCIPipelineInReleaseFile}/{NameOfArtifacts}/{URL}*.ps1'

resources:
 pipelines:
  - pipeline: CI
    source: 'build-pipeline-CI'

steps:
 - task: AzurePowerShell@5
   inputs:
     azureSubscription: ${{parameters.subName}}
     ScriptType: 'FilePath'
     ScriptPath: '$(Pipeline.Workspace)/CI/drop-self/folder1/Powershellnewscript.ps1'
     azurePowerShellVersion: 'LatestVersion'

Upvotes: 1

Related Questions