在Jenkins上以管理员身份运行批处理文件? [英] Run batch file as administrator on Jenkins?

查看:2072
本文介绍了在Jenkins上以管理员身份运行批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Win8 x64上使用Jenkins来构建(msbuild),打包(cspack),运行(csrun)和测试(nunit)一个Azure云服务项目. Azure云服务仿真器需要以管理员身份运行,而且我们需要绑定到端口80/443(因此不能使用精简"仿真器).

We're using Jenkins on Win8 x64 to build (msbuild), package (cspack), run (csrun) and test (nunit) an azure cloud services project. The Azure cloud service emulators need to run as administrator plus we need to bind to ports 80/443 (so can't use "lite" emulators).

我们通过Jenkins运行的简单.bat文件进行上述操作.通常,没有用户登录到计算机,它会启动,并且Jenkin作为服务运行,可以持续监视我们的GIT存储库和有关故障的电子邮件.管理员仅出于维护目的手动登录到计算机(例如,应用补丁或重启计算机等)

We're doing the above via a simple .bat file that Jenkins runs. Typically no user logs into the machine, it boots up and Jenkin's runs as a service that keeps monitoring our GIT repo and emails on failures. An admin manually logs into the machine just for maintenance (eg. apply patches or reboot machine etc)

我们如何配置Jenkins以管理员身份运行.bat而无需人工干预?

在桌面UI中,我们可以右键单击命令提示符,以admin身份运行,确认UAC提示符,获取提升权限的提示符并运行.bat文件.

With a desktop UI we can right click a command prompt, run as admin, acknowledge the UAC prompt, get the elevated privilege prompt and run the .bat file.

推荐答案

我们的解决方案是将Jenkins的服务作为单独的本地管理员用户运行.安装Jenkins之后,开始=>'服务'=>滚动到Jenkins服务=>右键单击=>属性=>登录" =>此帐户" =>指定本地管理员帐户.

Our solution was to run the Jenkins' service as a separate local admin user. After installing Jenkins, Start => 'services' => Scroll to the Jenkins service => right click => properties => "log on" => "this account" => specify a local admin account.

希望在Jenkins的较新版本中,它可以作为标准的网络服务使用,但由于某些原因,它与我们的包装盒不兼容.

Hopefully in newer Jenkins' builds it can work as the standard NETWORK SERVICE but for some reason it didn't with our box.

这篇关于在Jenkins上以管理员身份运行批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆