在Azdo中,可以使用Powershell任务以内联方式或从文件路径中运行Powershell脚本。
- task: PowerShell@2
displayName: 'Run PowerShell script inline'
inputs:
targetType: 'inline'
script: |
Write-Host "Hello, World!"
# 在此处添加其他Powershell代码
这个示例中,Powershell脚本在script输入参数中直接以内联方式提供。
首先,将Powershell脚本文件(例如script.ps1)添加到源代码存储库中。
然后,可以使用以下示例代码在Azdo中运行Powershell脚本:
- task: PowerShell@2
displayName: 'Run PowerShell script from file path'
inputs:
targetType: 'filePath'
filePath: 'path/to/script.ps1'
在filePath输入参数中,指定Powershell脚本文件的相对路径。
这两种方法都可以在Azdo中使用Powershell脚本。根据您的需求,选择适合您的方式。