我有下面的PowerShell
脚本,它在windows server 2019
的节点上从Jenkins
运行(它假设在sql server
上运行deploy
(:
$Username = $args[0]
$Password = $args[1]
$Env= $args[2]
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
echo "******** Start SQL Deploy ********"
echo "----- B4 Start-Process Powershell.exe -----"
Start-Process -FilePath "msbuild" -ArgumentList '"Database ServicesDatabase Services.sqlproj"','/t:deploy','/p:Configuration=Release','/p:TargetConnectionString=$Env','/p:BlockOnPossibleDataLoss=True','/p:TargetDatabase="test"','-fl','-flp:logfile=msbuild.log' -wait -LoadUserProfile -credential $cred
echo "----- After Start-Process Powershell.exe -----"
我的输出是:
******** Start SQL Deploy ********
----- B4 Start-Process Powershell.exe -----
----- After Start-Process Powershell.exe -----
我们可以清楚地看到Start-Process
没有被执行。重要的是要说它在本地对我有效,只有当我开始使用node
时,它才开始发生。
我在詹金斯论坛上看到类似的问题,但没有人对此发表评论:詹金斯-63978
我在这里得到了答案(也是从一些SO线程中得到的(:
https://community.spiceworks.com/topic/2317074-powershell-command-start-process-not-getting-executed-on-remote?page=1#entry-9166826