Building Jenkins in Eclipse

121 views
Skip to first unread message

Gerry Storm

unread,
Dec 31, 2018, 12:52:22 PM12/31/18
to Jenkins Users
I have tried to follow instructions in https://wiki.jenkins.io/display/JENKINS/Building+Jenkins:

// check out the workspace
$ git clone https://github.com/jenkinsci/jenkins.git
// Download dependencies and build with Maven
// Note: mvn install may be a prerequisite for other mvn targets
$ cd jenkins
$ mvn -Plight-test install

All went fine.

After that I followed instructions in
https://wiki.jenkins.io/display/JENKINS/Setting+up+Eclipse+to+build+Jenkins.


I tried several times and Eclipse ALWAYS finds errors after it imports the projects. (see attached screenshot).
I am a newbie so maybe the instructions imply stuff I am not familiar with.

My goals are:
  1. Build Jenkins from source in Eclipse
  2. Run it under a debugger so that I can make myself familiar with the flow.

Please help.
Screenshot from 2018-12-31 09-48-49.png

Ullrich Hafner

unread,
Jan 1, 2019, 10:58:23 AM1/1/19
to Jenkins Users
I’m not sure if one of the developers is still using Eclipse. Did you try in IntelliJ (or is that not an option)?

BTW: I think your questing is better suited for the dev list, see Jenkins Developers <jenkin...@googlegroups.com>.


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a00369ef-2bd3-470e-a787-e7a9bfaca2f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Screenshot from 2018-12-31 09-48-49.png>

James Nord

unread,
Jan 1, 2019, 4:52:09 PM1/1/19
to jenkins...@googlegroups.com
Alas that page is complete bunkum... if you are using eclipse make sure you use a distribution with m2eclipse (or add it) then after building Jenkins at the command line (mvn install -DskipTests) import the projects in the normal eclipse way as a "Maven" project.

/James

Gerry Storm

unread,
Jan 2, 2019, 4:31:40 PM1/2/19
to Jenkins Users
Thank you James. It is no picnic for a newbie especially with broken instructions. I wonder how people join under these circumstances. Maybe there is a different place/document/tutorial?

Anyway, how do I make sure that the distribution I get with cloning contains m2eclipse and if it does not how can I add it as you advise?

Thank you for your patience.

Jan Monterrubio

unread,
Jan 2, 2019, 5:12:22 PM1/2/19
to jenkins...@googlegroups.com
For newer versions of eclipse (2018.12, or after Photon, since they got rid of names)), there should be integration with maven out of the box. If that doesn't work, you can install a plugin, following these instructions: http://www.eclipse.org/m2e/

You mostly go to the About -> Install New Software / Eclipse MarketPlace and search for m2e. That basically sets up integration for eclipse to work with the maven generated locations (maven will put everything under the target/ folder). 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Gerry Storm

unread,
Jan 2, 2019, 5:30:44 PM1/2/19
to Jenkins Users
I tried it again. I cloned the repository from scratch, ran mvn install -DskipTests, then imported four projects:
cli
jenkins
jenkins-core
jenkins-war

The eclipse found tons of warnings and 13 errors. The errors included:
  1. XML with invalid characters
  2. Maven error failure to run task  generate source:              <execution>
                    <phase>generate-sources</phase>
                    <id>gulp bundle</id>
                    <goals>
                      <goal>gulp</goal>
                    </goals>
                    <configuration>
                      <arguments>jshint bundle</arguments>
                    </configuration>
                  </execution>
  3. The import hudson.cli.client cannot be resolved    CLI.java    /cli/src/main/java/hudson/cli    line 26    Java Problem
  4. Some other Java problems like wrong return value etc.

I am still in the dark as to how to make it work.


On Monday, December 31, 2018 at 9:52:22 AM UTC-8, Gerry Storm wrote:

Steffen Elste

unread,
Jan 3, 2019, 3:57:14 AM1/3/19
to Jenkins Users
Hi,
gave it at try this morning.

I downloaded the current 'Eclipse IDE for Enterprise Java Developers' (the smaller 'Eclipse IDE for Java Developers' should do as well).
Cloned the repository - without importing any projects in the first place - then imported 'Existing Maven Projects' into the workspace.
Eclipse then recognizes a missing m2e extension and displays a dialog to automatically install it - of course it's possible to do that manually beforehand, the extension is called M2E Buildhelper Connector.

There are a couple of errors after Eclipse finishes compiling the code - the missing 'hudson.cli.client' import is easy to fix: m2e doesn't realize that the source for localized messages is located in 'target/generated-sources/localizer' - You simply have to add that directory to the build path of the CLI project.

I'm still faced with an XML and two JSON errors, plus there are two compile errors left (in 'DelegateSecurityManager' and 'DescriptorExtensionList') ... (Java 8 issue?!)

Well, although Eclipse has gotten better of the last couple of years with respect to Maven integration it is - in my opinion - still the worst of the 'Big Three'.
Apache NetBeans and IntelliJ IDEA are much better choices if You use build systems like Maven or Gradle.

Btw, i agree with James Nord - the instructions are totally outdated if not outright wrong for Eclipse Neon upwards and should either be fixed or removed.
Cheers,

Steffen

Baptiste Mathus

unread,
Jan 3, 2019, 5:37:10 AM1/3/19
to jenkins...@googlegroups.com
@Steffen and James, can you pretty please update the wiki page for Eclipse? I'd do it myself, but I don't use Eclipse anymore, so my experience is ~3 years outdated now.

IMO, do not hesitate to remove many things, and make it very short, so that it does not become stale too quickly.

For the `target/generated-sources/localizer'` path that does not get added, I just checked, and I think I know the reason.
It's using the quite standard build-helper-maven-plugin, and so M2E should be automatically configuring paths, but the support for M2E got added only in 3.0.0.

Filed https://github.com/jenkinsci/jenkins/pull/3831 to help this. Can you please check that bumping this manually on your machine does fix this issue when importing with Eclipse ?

Thanks


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Steffen Elste

unread,
Jan 3, 2019, 7:38:03 AM1/3/19
to Jenkins Users
Hi Baptiste,
i did a quick check - removed the projects from the workspace, deleted all Eclipse-related files and folders, then bumped the version of the plugin up to 3.0.0 - but i still get the compile error, the build path is not set.

Can You give me a hint on how to go about updating the wiki, i'll give it a try?!
Regards,

Steffen

Steffen Elste

unread,
Jan 3, 2019, 8:17:18 AM1/3/19
to Jenkins Users
Hi,
after i modified the pom.xml of the cli project to include

        <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
         <version>3.0.0</version>
         <executions>
             <execution>
                 <id>add-source</id>
                 <phase>generate-sources</phase>
                 <goals>
                     <goal>add-source</goal>
                 </goals>
                 <configuration>
                     <sources>
                         <source>${project.build.directory}/generated-sources/localizer</source>
                     </sources>
                 </configuration>
             </execution>
         </executions>
      </plugin>


and re-imported everything the build path is set up correctly.
Cheers,

Steffen

Gerry Storm

unread,
Jan 3, 2019, 11:55:10 AM1/3/19
to jenkins...@googlegroups.com
Thank you all very much. I am not particularly fond of Eclipse per se. I have used it in the past and it was my first choice. If you think Apache NetBeans or IntelliJ IDEA are better I will switch to one of those. Which one would you recommend and are there instructions available I could follow?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Jan Monterrubio

unread,
Jan 3, 2019, 11:56:48 AM1/3/19
to jenkins...@googlegroups.com
I personally use intellij idea, since it lets you import a project ( and if it is maven it will wire things up on its own). 
https://blog.jetbrains.com/idea/2008/03/opening-maven-projects-is-easy-as-pie/


Gerry Storm

unread,
Jan 3, 2019, 3:08:25 PM1/3/19
to jenkins...@googlegroups.com
I have tried inlelliji and still got one error when building projects:
Error:(26, 25) java: package hudson.cli.client does not exist

in cli/src/main/java/hudson/cli/CLI.java at "import hudson.cli.client.Messages;"



Gerry Storm

unread,
Jan 3, 2019, 3:19:57 PM1/3/19
to jenkins...@googlegroups.com
I'm a bit surprised. jenkins is widely used and it looks looks like there are tons of contributors. I assumed it would be a breeze to build it from the source. I wonder if this is just my bad luck?

Slide

unread,
Jan 3, 2019, 3:25:05 PM1/3/19
to Jenkins User Mailing List
It could be your bad luck, I have never had the same issues you are having. I just imported the top level directory into IntelliJ IDEA as a Maven project and it worked flawlessly for me. 


For more options, visit https://groups.google.com/d/optout.


--

Bassam Khouri

unread,
Jan 3, 2019, 4:05:30 PM1/3/19
to jenkins...@googlegroups.com
I had an issue trying to create a plugin one.  I has a settings.xml in my ~/.m2 folder.  If you've got a settings.xml file, I wonder if it can be causing the issue you are encountering.  Back it up, remove it, and see if you can build.

---
"What we can or cannot do, what we consider possible or impossible, is rarely a function of our true capability. It is more likely a function of our beliefs about who we are." - Tony Robbins


Ullrich Hafner

unread,
Jan 3, 2019, 6:23:16 PM1/3/19
to Jenkins Users
Building is quite easy:-) Just importing it into an IDE is complex since Jenkins uses a lot of hacks around the maven infrastructure so it does not work out of the box. 

E.g., the compile error in IntelliJ is due to missing generated resource files. These generated sources are not picked up automatically. You need to make sure that the folder target/generated-sources/localizer is recognized as source folder. 

Gerry Storm

unread,
Jan 3, 2019, 7:42:29 PM1/3/19
to jenkins...@googlegroups.com
Thank you Ullrich and all.
I was able to import and build jenkins as follows:

2) cd jenkins; mvn install -DskipTests
3) Started inlellij, imported and built the projects, no errors just tons of warnings.

I now want to debug the jenkins.war. I created a debug configuration following https://stackoverflow.com/questions/21114066/attach-intellij-idea-debugger-to-a-running-java-process.

Then I started the application using the command: mvnDebug jenkins-dev:run and connected from intellij,
I saw a bunch of info in the terminal windows where I ran mvnDebug and finally the error:

mvnDebug jenkins-dev:run
Preparing to execute Maven in debug mode
Listening for transport dt_socket at address: 8000
[INFO] Scanning for projects...
[WARNING] The POM for org.apache.maven.plugins:maven-checkstyle-plugin:jar:3.0 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-checkstyle-plugin:3.0: Plugin org.apache.maven.plugins:maven-checkstyle-plugin:3.0 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-checkstyle-plugin:jar:3.0 in http://repo.jenkins-ci.org/public/ was cached in the local repository, resolution will not be reattempted until the update interval of repo.jenkins-ci.org has elapsed or updates are forced
[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failure to find org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 in http://repo.jenkins-ci.org/public/ was cached in the local repository, resolution will not be reattempted until the update interval of repo.jenkins-ci.org has elapsed or updates are forced
Downloading from repo.jenkins-ci.org: http://repo.jenkins-ci.org/public/org/apache/maven/plugins/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloading from repo.jenkins-ci.org: http://repo.jenkins-ci.org/public/org/codehaus/mojo/maven-metadata.xml
Downloaded from repo.jenkins-ci.org: http://repo.jenkins-ci.org/public/org/apache/maven/plugins/maven-metadata.xml (9.9 kB at 15 kB/s)
Downloaded from repo.jenkins-ci.org: http://repo.jenkins-ci.org/public/org/codehaus/mojo/maven-metadata.xml (20 kB at 30 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 19 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 kB at 28 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.402 s
[INFO] Finished at: 2019-01-03T16:34:25-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'jenkins-dev' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/gerry/.m2/repository), repo.jenkins-ci.org (http://repo.jenkins-ci.org/public/), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException


Baptiste Mathus

unread,
Jan 4, 2019, 2:57:36 AM1/4/19
to jenkins...@googlegroups.com
That is definitely abnormal. This is an Eclipse bug then, because that configuration is already inherited by the cli module (you can check yourself using mvn help:effective-pom).

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Gerry Storm

unread,
Jan 4, 2019, 2:49:15 PM1/4/19
to Jenkins Users
I finally managed to run Jenkins with a remote debugger using intellij.
cd war; mvnDebug jenkins-dev:run

However I am a little puzzled. I used (remote) debuggers in the past and usually the debugger presents the source and offers the user an opportunity to set breakpoints, watch-points and so on. I see nothing like this when following the instructions. The app just ran and was able to see the jenkins start page via the browser.

How do I see the source and set breakpoints just before the app runs?
After all it is just a java application.


On Monday, December 31, 2018 at 9:52:22 AM UTC-8, Gerry Storm wrote:
Reply all
Reply to author
Forward
0 new messages