windows - Windows 上的 Jenkins 无法使用 WinRM 部署?
问题描述
我有一个古老的代码库,我正试图将其提升到现代标准。其中大部分是使用 Visual Studio 在 Windows 上编写的,因此我需要一个基于 Windows 的构建服务器才能使用 MSBuild 管道。我有一个主要工作的 Jenkins CI 管道,它从 Github webhook 中提取,应该部署到我本地网络上的 Windows PC。我已经测试过这适用于我的工作站和构建服务器上的任何其他用户。我知道 Jenkins 以“NT AUTHORITY\System”用户身份运行作业,并且我过去曾使用 SysInternals PSExec 弹出并设置我的 ssh 密钥,等等。问题在于部署步骤;我正在使用 PowerShell 脚本压缩和复制构建输出,并使用New-PSSession
, 和Copy-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
当var 无法填充时,我生成了第二个错误。这是第 95 行:
$sess = New-PSSession -ComputerName $TargetHost -Credential $cred
我相信我听说过系统用户对网络访问有一些限制?有没有办法解决这个问题?
我的意思是,如果没有其他方法可以做到这一点,我可以将其 scp 完成,但如果我能侥幸逃脱的话,我真的很想把我所有的 shell 脚本都放在 pwsh 中。谢谢。
[编辑:TL;DR,我想我可以修改 Jenkins 以作为不同的用户运行,但为什么它还没有像那样运行?这对我来说似乎很奇怪,默认安装在没有网络访问权限的用户上,我猜?]
解决方案
我最终在 Windows 服务中以不同用户的身份运行 Jenkins,特别是“常规”登录用户。这使它成功地进行了部署。
推荐阅读
- web-services - wsimport 实用工具如何在后端创建具有包结构的类?这背后的背景机制是什么?
- kubernetes - 来自 openstack.org/standalone-cinder 的provisioner kubernetes.io/cinder 之间的区别
- java - Drive API:更改所有者时权限不足
- angular5 - 安装特定的角度版本不起作用(Angular 5.2.10)
- javascript - jquery bootstrap 4 打字稿。使用 jquery 关闭模式不起作用
- python - InvalidArgumentError(参见上面的回溯):没有注册 OpKernel 以支持具有这些属性的 Op 'MklConv2DWithBias'
- c# - 使用 DistinguishedName 查询 Active Directory
- java - Yodlee Sample App 卡在“Checking Cobrand Login Configurations”;无法登录
- javascript - 动态提交表单并显示输入的值而无需重新加载
- ruby-on-rails - RoR 更新字段 - 基于用户角色的金额限制?