简体   繁体   English

使用 OpenJDK 将 Jenkins 节点/代理作为 Windows 服务运行

[英]Running Jenkins Node/Agent as a Windows Service with OpenJDK

I have a Windows virtual machine with OpenJDK 13 installed that I would like to setup as a Jenkins node/agent.我有一个安装了 OpenJDK 13 的 Windows 虚拟机,我想将其设置为 Jenkins 节点/代理。

When I create the node configuration using the Jenkins UI and select Launch Method: Launch Agent by connecting it to the master it provides a link to download slave-agent.jnlp当我使用 Jenkins UI 和 select 创建节点配置时

On a system with the original jdk/jre older than version 9, which contains java web start, if I run that jnlp file, it brings up a window with a menu that includes an option File - Install as A Service在具有早于版本 9 的原始 jdk/jre 的系统上,其中包含 java web 启动,如果我运行该 jnlp 文件,它会显示一个 Z05B8C74CBD96FBF2DE4C1A352702 选项,该菜单包含 AFB4 选项

However, as OpenJDK (and I believe any JRE/JDK versions greater than 8) do NOT contain Java Web Start, I cannot seem to gain access to that option.但是,由于 OpenJDK(并且我相信任何大于 8 的 JRE/JDK 版本)不包含 Java Web Start,我似乎无法访问该选项。

I am able to successfully run java -jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory" and have the node register with Jenkins, but it is not running as a service. I am able to successfully run java -jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory" and have the node register with Jenkins, but it is not running as a服务。

I had an older agent that was still using old version of JRE, so I looked at its Jenkins service configuration and unfortunately it seems to be relying on executable(s), .config file(s), and xml file(s), which I cannot determine the source of, beyond they must be created when running the "Install as a service" instructions from slave-agent.jnlp我有一个仍在使用旧版本 JRE 的旧代理,所以我查看了它的 Jenkins 服务配置,不幸的是它似乎依赖于可执行文件、.config 文件和 xml 文件,其中我无法确定它们的来源,除了在从 slave-agent.jnlp 运行“作为服务安装”指令时必须创建它们之外

I also attempted to use IcedTea-Web which is apparently supposed to be a Java Web Start replacement, but I've had no success.我还尝试使用 IcedTea-Web,它显然应该是 Java Web 开始替换,但我没有成功。

Can anyone tell me how to setup a Windows machine running OpenJDK as a Jenkins node/agent with the Jenkins node/agent components running as a Windows service?谁能告诉我如何设置运行 OpenJDK 的 Windows 机器作为 Jenkins 节点/代理,并且 Jenkins 节点/代理组件作为 ZAEA06EBAB226 服务运行?

I had a similar issue and now I use NSSM .我有一个类似的问题,现在我使用NSSM

  1. Download NSSM下载NSSM
  2. Open a cmd and install the service (I used JenkinsService as Servicename):打开cmd并安装服务(我使用 JenkinsService 作为服务名称):
     <path to nssm.exe>\nssm install <Servicename>
  3. Insert the path to the jdk to the field Path将jdk的路径插入到字段Path
  4. add the rest to the field Arguments :将 rest 添加到字段Arguments
     -jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory"
  5. Click on install the service点击安装服务

Now you can check the new service JenkinsService in the windows service manager.现在您可以在 windows 服务管理器中查看新服务 JenkinsService。 As soon as it's running you can check the connection to the master.一旦它运行,您就可以检查与主服务器的连接。

If you want to setup a Java base application as a service, I believe the best option would be to use Procrun from Apache .如果您想将 Java 基础应用程序设置为服务,我相信最好的选择是使用来自 Apache 的Procrun It is the exact method that Tomcat uses.就是 Tomcat 使用的确切方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM