作为持续集成的一部分在远程计算机上运行程序

发布于 2024-08-08 08:16:12 字数 245 浏览 2 评论 0原文

作为发布打包的一部分,我们使用 TeamCity、nant 和 psexec 在远程计算机上运行命令。当我从控制台运行 nant 时一切正常,但从 teamcity 运行时 psexec 有 50% 的时间挂起(冻结)。
我浏览了许多论坛,似乎有一些解决方法会增加调用的复杂性并涉及丢失命令的输出和错误代码。
有谁知道在远程计算机上运行命令的更简单方法?
我不介意在远程计算机上设置一些应用程序,例如 telnet 服务器,有什么建议吗?
谢谢

We use TeamCity, nant and psexec to run a command on a remote machine as part of the release packaging. Everything works fine when I run the nant from the console but when running from teamcity psexec hangs (freezes) 50% of the times.
I looked through many forums and there seems to be workarounds that increase complexity of the call and involve loosing the output and the errorcode of the command.
Does anyone know an easier way to run a command on a remote machine?
I don't mind setting up some application on the remote machine, like a telnet server, any advices on what to do?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

找个人就嫁了吧 2024-08-15 08:16:12

我通过 RemCom 和名为 ExecParse 的自定义 MSBuild 任务的组合解决了这个问题。

RemCom,因为它不会对 STDOUT 做奇怪的事情(从而挂起构建)。我们使用 ExecParse 来捕获远程任务的输出,并从输出中解析退出代码,因为标准的 MSBuild Exec 任务不捕获输出。一些捕获输出的 NAnt 等效项可以工作。

我在博客文章中详细介绍了这一点: “持续集成:使用 TeamCity、MSBuild、RemCom 和 ExecParse 执行远程任务”

I have solved this issue with a combination of RemCom and a custom MSBuild task called ExecParse.

RemCom, because it doesn't do odd things with STDOUT (thus hanging the build). We used, and ExecParse to capture the output of the remote task, and parse the Exit Code from the output, because the standard MSBuild Exec task does not capture output. Some NAnt equivalent that captures the output would work.

I've detailed this in a blog post: "Continuous Integration: Executing Remote Tasks with TeamCity, MSBuild, RemCom, and ExecParse"

晨曦÷微暖 2024-08-15 08:16:12

PsExec 使用标准输入/输出执行一些奇怪的操作,并且从 Java(TeamCity 构建于其上)调用此操作会引发各种问题和稳定性问题。 psexec -d 不起作用。

我通过在 Team City 中使用 Powershell 解决了这个问题。

下面的脚本停止远程服务器上的 IIS 7 应用程序池:

[string]$HostName = "myWebServer"
[string]$Cmd = "C:\Windows\System32\inetsrv\appcmd.exe stop apppool MyMainAppPool” 
Invoke-WmiMethod -class Win32_process -name Create -ArgumentList ($Cmd) -ComputerName $HostName

有关更多信息,请参阅我的博客:http://blog. Degree.no/2012/03/executing-commands-and-programs-on-a-remote-machine-using-powershell/

PsExec does some funky things with the standard input/output, and invoking this from Java (which TeamCity is built on) raises all kinds of problems and stability issues. psexec -d did not work wither.

I solved it by using Powershell in Team City.

The script below stops an IIS 7 ApplicationPool on a remote server:

[string]$HostName = "myWebServer"
[string]$Cmd = "C:\Windows\System32\inetsrv\appcmd.exe stop apppool MyMainAppPool” 
Invoke-WmiMethod -class Win32_process -name Create -ArgumentList ($Cmd) -ComputerName $HostName

More about it on my blog: http://blog.degree.no/2012/03/executing-commands-and-programs-on-a-remote-machine-using-powershell/

梨涡 2024-08-15 08:16:12

如何在 psexec 上设置(nant)超时并重复调用直到没有超时发生?

How about putting a (nant) time-out on the psexec and repeat the call until no time-out happens?

迷荒 2024-08-15 08:16:12

我将 PSExec 与 -d 选项一起使用(不要等待它完成)并捕获返回代码。使用 -d 时的返回码是远程系统上运行的进程的进程 ID。然后我使用 PSList 轮询远程系统以获取进程 ID,直到我在远程系统上不再找到它为止。

I use PSExec with the -d option (don't wait for it to finish) and capture the return code. The return code when you used -d is the process ID of the process running on the remote system. then I use PSList to poll the remote system for the process ID until I don't find it on the remote system any longer.

清晨说晚安 2024-08-15 08:16:12

如果您在远程计算机上设置 TeamCity 构建代理并让它在本地执行操作,并向其传递带有“工件依赖项”的二进制文件,会发生什么?

What happens if you setup TeamCity build agent on remote machine and let it perform the operation locally, passing it the binaries with "Artifact Dependencies"?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文