Azure Devops Piepeline-Yaml Powershell脚本路径

问题描述

我想问你,是否有人知道如何在Azure Devops Pipeline Yaml语法中创建正确的Powershell路径。

看起来像我的YAML(当前):

trigger:
- develop

pool:
  vmImage: 'ubuntu-latest'

steps:

- task: PowerShell@2
  inputs:
    filePath: './scripts/script.ps1'

看起来像我的目录:

enter image description here

哪种路径返回管道:

获取内容:/home/vsts/work/1/s/scripts/script.ps1:12

什么样的错误返回管道:

## [错误] PowerShell退出代码为“ 1”。

解决方法

将需要查看您的发布任务的外观和相对路径。尝试添加-powershell Get-ChildItem -Path $(Build.ArtifactStagingDirectory) -recurse,这会列出所有路径,以便您可以看到脚本的完整路径。

,

我想问你是否有人知道如何创建正确的路径 在Azure Devops Pipeline Yaml语法中添加Powershell。

不是PS找不到您的脚本,而是错误消息表明您的xx.ps1文件中的line12出了问题。

在您在此处共享脚本内容之前,我无法找到问题。我的建议是,您应该使用System.Debug=true重新运行管道以获取详细的错误消息,并在那里获得提示。

,

正确答案:

- task: PowerShell@2
  inputs:
    filePath: '$(Agent.BuildDirectory)/s/scripts/script.ps1'