简体   繁体   English

如何从 jenkins 的现有项目生成 .hpi 插件

[英]How to generate an .hpi plugin from an existing project for jenkins

I'm trying to use the performance plugin for jenkins, but the latest version has some issues as described in the link:我正在尝试为 jenkins 使用性能插件,但最新版本有一些问题,如链接中所述:

https://issues.jenkins-ci.org/browse/JENKINS-27100 https://issues.jenkins-ci.org/browse/JENKINS-27100

One of the comments is: "I think this issue have fixed in the trunk, check out and build locally seem to fix the issue. I'm using version Jenkins ver. 1.596.2"其中一条评论是:“我认为这个问题已经在后备箱中解决了,在本地检查和构建似乎可以解决这个问题。我使用的是 Jenkins 版本 1.596.2”

I'm trying to do the same, download the project and build it locally.我正在尝试做同样的事情,下载项目并在本地构建它。 This is the part that I don't know how to do.这是我不知道该怎么做的部分。 I have downloaded eclipse (mars), but I don't even know how to import the project and build it.我已经下载了 eclipse (mars),但我什至不知道如何导入项目并构建它。

This is the project:这是项目:

https://github.com/jenkinsci/performance-plugin https://github.com/jenkinsci/performance-plugin

I have downloaded it and researched on how to import it.我已经下载并研究了如何导入它。 Apparently this is a maven project (as I know that maven can create the .hpi files).显然这是一个 maven 项目(因为我知道 maven 可以创建 .hpi 文件)。 But I haven't been able to understand more on how to actually import it.但我一直无法更多地了解如何实际导入它。 I can try different tutorials but I'm not even sure if I'm going on the right direction.我可以尝试不同的教程,但我什至不确定我是否朝着正确的方向前进。

My plan is to figure out how to import it as a maven project and investigate how to generate the .hpi.我的计划是弄清楚如何将其作为 maven 项目导入并研究如何生成 .hpi。 I'm guessing this should work, if I'm mistaken please let me know how can I proceed.我猜这应该有效,如果我弄错了,请告诉我如何继续。

Thanks谢谢

Update更新

I have been able to to install maven locally and in Eclipse.我已经能够在本地和 Eclipse 中安装 maven。 However, in both I get a couple of errors:但是,在两者中我都遇到了一些错误:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre1.8.0_91\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.571 s
[INFO] Finished at: 2016-05-26T17:34:22-05:00
[INFO] Final Memory: 17M/248M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project performance: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre1.8.0_91\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.

Now, I already had the jdk set in JAVA_HOME.现在,我已经在 J​​AVA_HOME 中设置了 jdk。 I'm not sure what I would be doing wrong here.我不确定我在这里会做错什么。

EDIT 2编辑 2

Fixed Edit 1. I've been able to build it successfully with the -mvn command.固定编辑 1. 我已经能够使用 -mvn 命令成功构建它。 But from eclipse I get the error:但是从 eclipse 中我得到了错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.9:test (default-test) on project performance: There are test failures.
[ERROR] 
[ERROR] Please refer to E:\eclipseWorkSpace\performance-plugin-master\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]

I can't seem to generate the .hpi as long as the error persists.只要错误仍然存​​在,我似乎就无法生成 .hpi。 I'm trying to find out how to solve it, but I haven't had any luck so far.我试图找出如何解决它,但到目前为止我还没有任何运气。

The tutorial is a good place to start教程是一个很好的起点

You can avoid an IDE to start with and just run您可以避免使用 IDE 启动并运行

mvn install

from the directory you put the source in. You will need maven3, JDK 6.0 as a minimum and a connection to the internet to get all the jar files you will need.从您放置源代码的目录中下载。您至少需要 maven3、JDK 6.0 和 Internet 连接才能获取您需要的所有 jar 文件。

I ended up moving to team city. 我最终搬到了团队城市。 DevOps in my company use team city so I have more support. 我公司的DevOps使用团队城市,所以我有更多的支持。 Although I also have some issues regarding team city config, I have been able to go farther. 虽然我也有一些关于团队城市配置的问题,但我能够走得更远。

A quick way for those who don't have Java JDK installed locally is utilizing docker.对于那些没有在本地安装 Java JDK 的人来说,一个快速的方法是使用 docker。

First, create a volume to reuse Maven local repository instead of downloading everything on every build:首先,创建一个卷来重用 Maven 本地存储库,而不是在每次构建时下载所有内容:

docker volume create --name maven-repo

Then, assuming you are in the root directory of your plugin project:然后,假设您位于插件项目的根目录中:

docker run --rm -it \
    -v maven-repo:/root/.m2 \
    -v "$(pwd)":/usr/src/mymaven \
    -w /usr/src/mymaven \
    maven:latest \
    mvn clean install

You can find other supported docker tags to use specific version of Java or Maven here .您可以在此处找到其他支持的 docker 标签以使用特定版本的 Java 或 Maven。

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

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