【发布时间】:2019-11-06 08:53:06
【问题描述】:
我有一个正在构建的 Azure Devops 部署管道设置,我可以毫无问题地部署到自托管虚拟机。
我有以下 powershell 脚本可以正确清除我的目标目录,留下 2 个不属于源代码控制的文件夹
Get-ChildItem -Path 'C:\inetpub\wwwroot\testDeploy\' -Recurse -exclude "pod","photos" |
Select -ExpandProperty FullName |
Where {$_ -notlike '*\pod\*' -and $_ -notlike '*\photos\*'} |
sort length -Descending |
Remove-Item -force
我尝试添加“PowerShell 脚本”任务,但我不知道如何将 PowerShell 脚本放入任务可以访问的文件夹中,即 $(System.DefaultWorkingDirectory)。任何人都可以建议我应该如何生成文件或将其存储在我的仓库中,然后由自托管的 Windows 代理访问
【问题讨论】:
-
是否要访问 PowerShell 脚本中的预定义变量?
-
不,脚本可以单独运行。我应该补充一点,我可以通过添加内联脚本来运行该过程,但我想了解如何在 repo 中维护它
-
您可以创建一个文件夹“PowerShell scripts”并将脚本放在那里。
-
您可以将您的脚本存储在 repos 中并由自我代理访问吗?
-
这个错误信息是你的脚本路径不正确造成的。 .ps1 文件路径应为“xxx_work\3\s\xxx.ps1”,而不是“a”文件下。
标签: azure-devops azure-pipelines azure-pipelines-release-pipeline azure-devops-self-hosted-agent