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

南笙酒味 提交于 2020-02-22 07:53:07

问题


I'm trying to use the performance plugin for jenkins, but the latest version has some issues as described in the link:

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"

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.

This is the project:

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). 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. 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. 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. I'm not sure what I would be doing wrong here.

EDIT 2

Fixed Edit 1. I've been able to build it successfully with the -mvn command. But from eclipse I get the error:

[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. I'm trying to find out how to solve it, but I haven't had any luck so far.


回答1:


The tutorial is a good place to start

You can avoid an IDE to start with and just run

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.




回答2:


A quick way for those who don't have Java JDK installed locally is utilizing docker.

First, create a volume to reuse Maven local repository instead of downloading everything on every build:

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.



来源:https://stackoverflow.com/questions/37469464/how-to-generate-an-hpi-plugin-from-an-existing-project-for-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!