Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a Jenkins plugin

We're using Jenkins, and are trying to automate deployments to our Artifactory server. We've downloaded the Artifactory plugin, and configured it, but it doesn't work. The list of repositories under "Resolution repository" and "Publishing repository" are blank.

Nothing appears in the log file to indicate there's any problems. I'm trying to call code from the Script Console, but I'm being hampered by the complete lack of documentation on creating a Jenkins plugin. There's a few tutorials, but they don't discuss details about how plugins get loaded by the system, or how I can get references to them to figure out what's going wrong.

How do I debug this thing?

like image 776
Chris B. Avatar asked Mar 04 '14 14:03

Chris B.


People also ask

How do I debug Jenkins plugins?

Just add hpi:run in "Command line" filed and start Debug as usual. When the console says that your "Jenkins is fully up and running", open a browser and go to http://localhost:8080/jenkins/ and your code will stopped at break point (if any).

How do I read Jenkins errors?

Go to the project page and Click on the failed build number from the 'Build History'. Look for the details: File at which the ERROR has occured, ERROR details. Then Click Workspace on the left and go to the specified file location.


2 Answers

You can download the source for the plugin from its github location in jenkinsci

Then as this uses the maven jenkins plugin framework you can then do

mvn hpi:run

from the commandline which will download all the jenkins jars and additional jars you need documentation

This will give you a test jenkins install on port 8080 of localhost which you can then connect to, create jobs, install plugins and run jobs

I debug this with intellij. Point intellij at the POM file and it should load all the maven commands into the maven toolbox, from here you can debug the plugin by debugging the hpi:run command.

You can do a similar thing with eclipse or possibly use mvnDebug inplace of mvn and attach a remote debugger https://stackoverflow.com/a/2935475/1213907

If the plugin does not have reference the Jenkins Maven repository, you must add it yourself in pom.xml or in ~/.m2/settings.xml:

  <pluginRepositories>
    <pluginRepository>
      <id>repo.jenkins-ci.org</id>
      <url>https://repo.jenkins-ci.org/public/</url>
    </pluginRepository>
  </pluginRepositories>
like image 132
KeepCalmAndCarryOn Avatar answered Sep 30 '22 13:09

KeepCalmAndCarryOn


Regarding the Artifactory plugin, try saving the configuration and reload the job config page. The logic behind this is to avoid a list of repositories to long, some servers has up 100 local repostoies and this way, by entering credential, you can display a list of only relevant repositories. There is an open issue to have a refresh button so there will be no need to save the config prior to displaying the list.

like image 39
elig Avatar answered Sep 30 '22 11:09

elig