This is a Maven project with Java sources. The mvn package command will produce an HPI file that is the Jenkins Plugin file that will need to be installed on your Jenkins Server.
- SET JAVA_HOME to the location of the JRE to build with (JRE 1.8 works)
- Clone the repo from https://github.com/jenkinsci/tfs-plugin.git
- change dir to the tfs-plugin folder
- run "mvn package"
- If you do not have Maven installed yet, here are instructions on how to install it on Windows.
- Initial build will have to download lots of libraries. This could take a few minutes.
- This produces tfs-plugin\tfs\target\tfs.hpi
To use Intellij IDEA as the editor for this project simply do the following after getting sources:
- Open the tfs-plugin folder (root folder) in IntelliJ (I installed IntelliJ 17 community edition from https://www.jetbrains.com/idea/)
- Go to File->Project Structure and click on Project
- Specify the Project SDK (Java 1.8 works)
You should now be able to build from within IntelliJ
- NOTE to build the hpi file you will have to
- bring up the Maven Projects tool window (View->Tool Windows->Maven Projects) and click the "execute maven goal" button
- Then type "package" in the "Command Line" text box (of the Execute Maven Goal dialog)
See https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial for information on how to debug the plugin. From within IntelliJ:
-
Create a new Run configuration (Run | Edit Configurations... | + )
-
Type = Maven
-
Name = run hpi
-
Working directory should be the full path to "../tfs-plugin/tfs" (NOTE this is NOT the root folder)
-
Command Line
hpi:run -Djetty.port=8090 -Dhudson.plugins.tfs.telemetry.isDeveloperMode=true
- or use whatever port you want
-
On the Runner tab
- Environment Variables == MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
- To set the environment variables, make sure you uncheck 'Use project settings' first. Then use the '...' to set the variable.
-
-
Run or Debug this configuration using the play and debug icons (top right)
- Set any breakpoints you want in IntelliJ
- Navigate to http://localhost:8090/jenkins
Note: this runs Jenkins on your local OS not in a Docker image. As such, any configurations you make are preserved between runs. You do not need to have Jenkins previously installed locally (IntelliJ will run Jenkins from a local JAR file).
The easiest method is to run Jenkins in a Docker image.
-
Install Docker for your OS (https://www.docker.com/community-edition)
-
Install and run the Jenkins image
docker run --name localJenkins -p 9191:9191 -p 50001:50001 --env "JENKINS_OPTS=--httpPort=9191" --env JENKINS_SLAVE_AGENT_PORT=50001 --env hudson.plugins.tfs.telemetry.isDeveloperMode=true jenkins
- NOTES:
- Note that this command line avoids port 8080 (the default) in case you have VSO deployed as well
- Look in the output for the admin password
- The output sent to the console is also where you will see any logger output
- Note the environment variable "hudson.plugins.tfs.telemetry.isDeveloperMode". It is important to set this variable so that AppInsights data is sent to right key
- This installs a Linux Jenkins server on Docker (NOT one based on Windows or the host OS)
- NOTES:
-
Setup Jenkins
- Go to http://localhost:9191
- Enter the admin password
- Install default plugins
- Run Jenkins
-
Install Plugin Manually
- Go to http://localhost:9191/pluginManager/advanced
- Browse to the tfs.hpi file and Upload it
- To update the plugin, repeat steps 1 and 2 and then restart Jenkins by going to http://localhost:9191/restart
-
To stop Jenkins and start from scratch
docker stop localJenkins docker container prune
Then repeat step 2 and 3 above