簡體   English   中英

Windows 上的 Jenkins 無法使用 WinRM 進行部署?

[英]Jenkins on Windows fails to deploy with WinRM?

我有一個舊的代碼庫,我正試圖將其提升到現代標准。 其中大部分是使用 Visual Studio 在 Windows 上編寫的,因此我需要有一個基於 Windows 的構建服務器才能使用 MSBuild 管道。 我有一個主要工作的 Jenkins CI 管道,它從 Github webhooks 攝取,並且應該部署到我的 local.network 上的 Windows PC。 我已經在我的工作站和構建服務器上測試過這對任何其他用戶都有效。 我知道 Jenkins 以“NT AUTHORITY\System”用戶身份運行作業,而且我過去曾使用 SysInternals PSExec 彈出並設置我的 ssh 密鑰,等等。 問題出在部署步驟中; 我正在使用 PowerShell 腳本壓縮和復制版本 output,並使用New-PSSessionCopy-Item -ToSession

我正在使用我正在使用 Get-Credential 用戶/通行證對構建的信用,我已經驗證它可以正常工作。 所有相關系統都在一個簡單的工作組中,不涉及域。

我的 deploy.ps1 腳本中的New-PSSession命令失敗並出現以下錯誤:

PS C:\Program Files (x86)\Jenkins\workspace\xxx> .\deploy.ps1

Compressing to C:\Windows\TEMP\tmpEBB2.tmp.zip
New-PSSession: C:\Program Files (x86)\Jenkins\workspace\xxx\deploy.ps1:95
Line |
  95 |  …     $sess = New-PSSession -ComputerName $TargetHost -Credential $cred …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | [205.208.87.185] Connecting to remote server 205.208.87.185 failed with the following error message :
     | WinRM cannot process the request. The following error with errorcode 0x8009030d occurred while using
     | Negotiate authentication: A specified logon session does not exist. It may already have been
     | terminated.    Possible causes are:   -The user name or password specified are invalid.   -Kerberos is
     | used when no authentication method and no user name are specified.   -Kerberos accepts domain user
     | names, but not local user names.   -The Service Principal Name (SPN) for the remote computer name and
     | port does not exist.   -The client and remote computers are in different domains and there is no trust
     | between the two domains.  After checking for the above issues, try the following:   -Check the Event
     | Viewer for events related to authentication.   -Change the authentication method; add the destination
     | computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.  Note that computers
     | in the TrustedHosts list might not be authenticated.    -For more information about WinRM
     | configuration, run the following command: winrm help config. For more information, see the
     | about_Remote_Troubleshooting Help topic.  Other Possible Cause:   -The domain or computer name was not
     | included with the specified credential, for example: DOMAIN\UserName or COMPUTER\UserName.
Write-Error: C:\Program Files (x86)\Jenkins\workspace\xxx\deploy.ps1:129
Line |
 129 |  Deploy-ToTargetHost
     |  ~~~~~~~~~~~~~~~~~~~
     | Could not establish session.

$sess無法填充時,我生成了第二個錯誤。 這是第 95 行:

$sess = New-PSSession -ComputerName $TargetHost -Credential $cred

我相信我聽說過系統用戶對網絡訪問有一些限制? 有什么辦法可以解決這個問題嗎?

我的意思是,如果沒有其他方法可以做到這一點,我可以將它 scp 過來,但我真的很想在 pwsh 中編寫我所有的 shell 腳本,如果我可以擺脫它的話。 謝謝。

[編輯:TL;DR,我想我可以修改 Jenkins 以作為不同的用戶運行,但為什么它還沒有像那樣運行? 這對我來說似乎很奇怪,默認安裝在沒有網絡訪問權限的用戶身上,我猜?]

我最終以 Windows 服務中的不同用戶身份運行 Jenkins,特別是“常規”登錄用戶。 這使得它成功地完成了部署。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM