首页 > 解决方案 > 通过 YAML 任务运行 powerscript 文件

问题描述

您是否有一些关于如何在 YAML 文件中的任务中运行 powershell 脚本文件的简单工作示例。就像这个一样?似乎我的无法获取并执行脚本,因为没有打印日志。

- task: PowerShell@2
    displayName: task 1
    inputs:
      targetType: 'filePath'
      filePath: scripts\sample_pwsh.ps1
      arguments: -Name someName

标签: azure-devopsazure-pipelinesazure-powershellazure-pipelines-yamlazure-yaml-pipelines

解决方案


  • 您正在使用正确的 PowerShell@2 任务语法。尝试确认您的文件路径。filePath 应该是从根目录开始的绝对路径。
  • 例如,文件路径:root/complete/path/scripts/sample_pwsh.ps1
  • 如果这不起作用,请尝试检查您的 ps1 脚本。

推荐阅读