perfpublisher-plugin

Jenkins perfpublisher plugin

Stars
7
Committers
10

+--------------------------------------------------+

  • README - HOW TO COMPILE - PLUGIN +
    +--------------------------------------------------+
    @author : Georges Bossert
    <[email protected]
    @date : 17/07/2009
    @version : 1.0

This document will introduce how to compile and run the PerfPublisher Plugin. More globaly, this "how to" can be used for any Jenkins plugin.

Summary

  1. Tools needed
    a. JDK 6.0
    b. Maven
    i. how-to install Maven on linux
  2. Files and Workspace layout
  3. Compile a project
  4. Debug a project
  5. Distributing a Plugin
  6. Links

  1. Tools needed

a. JDK 6.0

In order to compile, run and debug any Jenkins Plugin, few tools need to be install. First, JAVA and it's JDK ( min. 6.0 ), since it's mainly developped in JAVA.

b. Maven

Right after, come with Maven2 which has to be fully
functionnal and able to download stuff over the
Internet.

i. how-to install Maven on linux
	1. Open a command terminal.
	2. Create a directory for your Maven install.
		mkdir /udd/[USER]/apache-maven
	3. Download the maven distribution archive to your install directory.
		wget http://apache.mirror99.com/maven/binaries/apache-maven-2.0.9-bin.tar.gz
	4. Extract the distribution archive.
		tar -zxf apache-maven-2.0.9-bin.tar.gz
		The file will be extracted too /udd/[USER]/apache-maven/apache-maven.
	5. Add the M2_HOME environment variable.
		export M2_HOME=/udd/[USER]/apache-maven/apache-maven-2.0.9
	6. Add the M2 environment variable.
		export M2=$M2_HOME/bin
	7. Add M2 environment variable to your path.
		export PATH=$M2:$PATH
	8. Make sure that JAVA_HOME is set to the location of your JDK.
	9. Test your new Maven setup.
		mvn --version
		If your setup is correct you should now see something like:
			Maven version: 2.0.9
			Java version: 1.6.0_03
			OS name: "linux" version: "2.6.22-14-generic" arch: "i386" Family: "unix"

We also have to register Jenkins repositories into Jenkins. Edit ~/.m2/settings.xml to be sure to have this declaration :

<profile>
  <id>jenkins</id>

  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>

  <repositories>
    <repository>
      <id>repo.jenkins-ci.org</id>
      <url>http://repo.jenkins-ci.org/public/</url>
    </repository>
    <repository>
      <id>m.g.o-public</id>
      <url>http://maven.glassfish.org/content/groups/public/</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>repo.jenkins-ci.org</id>
      <url>http://repo.jenkins-ci.org/public/</url>
    </pluginRepository>
    <pluginRepository>
      <id>m.g.o-public</id>
      <url>http://maven.glassfish.org/content/groups/public/</url>
    </pluginRepository>
  </pluginRepositories>

</profile>
<mirror>
  <id>repo.jenkins-ci.org</id>
  <url>http://repo.jenkins-ci.org/public/</url>
  <mirrorOf>m.g.o-public</mirrorOf>
</mirror>

  1. Files and Workspace layout

PerfPublisher as any Jenkins Plugin is mainly based on 4 types of data.

pom.xml : The controller of it's own Maven build

src/main/java : Contains all the Java sources.

src/main/ressources : Contains all the Jelly and others ressources files.

src/main/webapp : Every files in the directory will be copy directly into the runtime of the Plugin. Must contain all the static components like images and HTML pages.


  1. Compile a project

In a shell, juste use the maven commands :

mvn clean : clean the sources and the previous build mvn compile : compile the sources


  1. Debug a project

Before starting debug, the environnement must be set. use this linux command to execute the debug on your host using port 8000

export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n"

As compiling, debuging only requires tu execute a maven command :

mvn hpi:run

If you open http://localhost:8080/ in your browser, you should see the Jenkins page running in Jetty. The MAVEN_OPTS portion launches this whole thing with the debugger port 8000, so you should be able to start a debug session to this port from your IDE.


  1. Distributing a Plugin

To create the package containing the needed files, run the following maven goal :

mvn package

This command should create an archive *.hpi, which is similar to *.jar, in the target directory. It's this file used to install the plugin .


  1. Links

Maven2 : http://maven.apache.org/ Jenkins : http://jenkins-ci.org/