在命令行中将Jenkins从属服务器安装为Windows服务 [英] Install Jenkins slave as a Windows service in command line
问题描述
我一直在Google上寻找很多有关如何在Windows中安装该服务的信息 命令行(因此无需手动交互),但我仍然坚持如何 获取jenkins-slave.exe
I have been looking a lot on Google on how to install the service in command line (so without manual interaction) but I am stuck on how to get the jenkins-slave.exe
我找到了那些指示 https://wiki.jenkins.io/display/JENKINS /Installing + Jenkins + as + a + Windows + service 但我不知道如何获取可执行文件.我已经下载并运行 带有右键的slave.jar,它连接了slave,但是exe 不会生成.
I found those instruction https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+as+a+Windows+service but I can't figure how to get the executable. I have downloaded and run the slave.jar with the right key, which connects the slave, but the exe is not generated.
我找到了此页面 https://github.com/kohsuke/winsw /blob/master/doc/installation.md#winsw-installation-guide 手动安装,但听起来像是在重新发明轮子时 罐子可以做到的.另外,WinSW.exe也有可能与众不同. 没有通过插件更新(我在其中看到了一些自动更新代码).
I found this page https://github.com/kohsuke/winsw/blob/master/doc/installation.md#winsw-installation-guide to install it manually but that sounds like re-invented the wheel when the jar can do it. Plus there is a risk the WinSW.exe is different and doesn't get updated by the plugin (I saw some automatic update code in it).
那么有什么方法可以下载jenkins-slave.exe或生成它? 还是有一种方法可以从命令行在命令行中运行作为服务安装" slave.jar?
So is there a way I can download the jenkins-slave.exe or generate it? or is there a way to run the "Install as a service" in command line from the slave.jar?
推荐答案
在与插件开发人员联系后,要回答我自己的问题:
To answer my own question, after having contacted the plugin developers:
没有实际方法可以直接从Jenkins下载exe,slave.jar通过远程协议从主服务器获取该exe.我创建了一个请求,要求能够通过URL下载(由开发人员建议),因此将来可能会提供.
There is no actual way to download the exe from Jenkins directly, the slave.jar gets it from the master via the remoting protocol. I have created a request to be able to download it via an URL (as suggested by the developer), so it might be available in the future.
现在,可执行文件是重命名的Windows Service Wrapper二进制文件: https://github.com/kohsuke/winsw 所以我以相同的方式使用了此二进制文件.
Right now the executable is a renamed Windows Service Wrapper binary: https://github.com/kohsuke/winsw so I used this binary the same way.
关于WinSW和XML文件使用的配置,我使用了GitHub存储库中的配置 https://github.com/jenkinsci/windows-slave-installer-module .这些版本在配置方面是兼容的.
Regarding the configuration used by WinSW and XML files, I used the one from the GitHub repository https://github.com/jenkinsci/windows-slave-installer-module. The versions are compatible in terms of the configuration.
因此,基本上,我下载了exe,从Jenkins获取了私钥,并使用原始插件中的配置创建了服务.然后,我使用jenkins-slave.exe install
安装该服务.
So basically I download the exe, get the private key from Jenkins and create the service using the configuration from the original plugin. Then I install the service using jenkins-slave.exe install
.
逐步:
- 从Jenkins(从节点"页面)获取JNLP命令以获取私钥,例如
java -jar slave.jar -jnlpUrl http://jenkins...
- 从Jenkins下载
slave.jar
文件(从JNLP命令获得) - 下载服务包装可执行文件,例如
http://repo.jenkins-ci.org/public/com/sun/winsw/winsw/2.1.0/winsw-2.1.0-bin.exe
- 设置用于运行服务的XML(可在模块中或直接在winsw网站上获得)
- 设置从属配置XML文件(在模块源代码上可用)
- 然后使用
jenkins-slave.exe install
安装服务
- Get the JNLP command from Jenkins (from the Node page) to get the private key, e.g.
java -jar slave.jar -jnlpUrl http://jenkins...
- Download the
slave.jar
file from Jenkins (gotten from the JNLP command) - Download the service wrapper executable, e.g.
http://repo.jenkins-ci.org/public/com/sun/winsw/winsw/2.1.0/winsw-2.1.0-bin.exe
- Setup the XML used to run the service (available in the module or directly on winsw website)
- Setup the slave configuration XML file (available on the module source code)
- Then install the service using
jenkins-slave.exe install
这篇关于在命令行中将Jenkins从属服务器安装为Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!