【问题标题】:Azure Devops Piepeline - Yaml Powershell Script PathAzure Devops 管道 - Yaml Powershell 脚本路径
【发布时间】:2021-01-20 10:54:50
【问题描述】:

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

我的 YAML 看起来如何(目前):

trigger:
- develop

pool:
  vmImage: 'ubuntu-latest'

steps:

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

我的目录看起来如何:

什么样的路径返回管道:

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

什么样的错误返回管道:

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

【问题讨论】:

    标签: azure yaml azure-pipelines azure-pipelines-yaml


    【解决方案1】:

    正确答案:

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

    【讨论】:

      【解决方案2】:

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

      不是 PS 找不到你的脚本,而是错误信息表明你的 xx.ps1 文件中的 line12 有问题。

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

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-08-27
          • 2019-06-01
          • 2020-05-23
          • 2020-01-18
          • 2021-06-23
          • 2019-04-06
          • 2019-02-18
          • 1970-01-01
          相关资源
          最近更新 更多