我们使用Azure DevOps Server 2019 (On)。
我想在Powershell中编写一个定制的Azure DevOps任务。到目前为止,我在网络上看到的例子都是关于在打字稿中创作的。
我在想-这是唯一的办法吗?例如,我们可以使用Powershell吗?
发布于 2020-03-24 08:57:56
是的,您可以在自定义构建任务中使用PowerShell。
您需要在task.json中编辑这一节
"execution": {
"PowerShell3": {
"target": "ps-script.ps1",
"workingDirectory": "$(currentDirectory)"
}
}您需要安装VstsTaskSdk Powershell模块:
root/buildtaskmkdir ps_modules,然后导航到新目录pwd应该读root/buildtask/ps_modulesSave-Module -Name VstsTaskSdk -Path .,将模块保存到磁盘。root/buildtask/ps_modules/VstsTaskSdk/0.10.0/*路径,它现在应该读取root/buildtask/ps_modules/VstsTaskSdk/*完整的教程存在这里。
您还可以看到在这 GitHub repo上使用PS进行自定义任务的示例。
注意:它只在windows机器中工作。
发布于 2020-03-24 08:57:29
是的,您可以在自定义任务中直接使用PS脚本。您可以这样配置task.json:
"execution": {
"PowerShell3": {
"target": "script.ps1",
"workingDirectory": "$(currentDirectory)"
}
}https://stackoverflow.com/questions/60822859
复制相似问题