Azure DevOps部署ADF CI/CD管道时无法定位PowerShell脚本路径
Azure DevOps CI/CD管道PowerShell脚本路径问题解决记录
问题概述
在@Alvin协助下搭建Azure DevOps CI/CD管道时,核心问题为无法正确定位pre-and post-deployment.ps1脚本的实际路径,导致任务执行失败。
配置的YAML管道代码
# Starter pipeline # Start with a minimal pipeline that you can customize to build and deploy your code. trigger: - main pool: vmImage: ubuntu-latest steps: - script: echo Hello, world! displayName: 'Run a one-line script' - script: | echo Add other tasks to build, test, and deploy your project. displayName: 'Run a multi-line script' - task: PublishBuildArtifacts@1 inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)' ArtifactName: 'drop' publishLocation: 'Container' - task: AzurePowerShell@5 inputs: azureSubscription: 'NewConnectionName' ScriptType: 'FilePath' ScriptPath: '$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/pre-and post-deployment.ps1' azurePowerShellVersion: 'LatestVersion'
执行报错信息
##[error]ENOENT: no such file or directory, stat '/home/vsts/work/1/s/caplogic-warehouse-dev-df/pre-and post-deployment.ps1'
排查及解决步骤
- 尝试通过图片路径信息定位脚本文件,未成功
- 切换至
adf-publish分支后,路径错误依然存在 - 按照@Wade建议上传
azure-pipelines-5.yml文件后,路径问题得到解决,但PowerShell脚本本身出现新的执行问题,将另行提交工单处理
内容的提问来源于stack exchange,提问作者Patterson
相关产品推荐
相关产品推荐

