wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Configure Jenkins to run a job on every commit in SVN repository Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Configure Jenkins to run a job on every commit in SVN repository" Watch "Configure Jenkins to run a job on every commit in SVN repository" New topic
Author

Configure Jenkins to run a job on every commit in SVN repository

David Spades
Ranch Hand

Joined: Feb 01, 2014
Posts: 201
I'm trying to use jenkins, but couldn't find any forum about jenkins, just a Jenkins mailing group. does anybody know if jenkins has such forum? thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

We handle Jenkins questions in this forum.


Customer surveys are for companies who didn't pay proper attention to begin with.
David Spades
Ranch Hand

Joined: Feb 01, 2014
Posts: 201
in that case, I'd like to ask how to manage a project and its unit tests and integration tests. should they be separated into different projects and thus, different build? why do we need to put unit test into jenkins? unit tests should only be done locally (IMHO) because only the developer would know about that. it makes sense to put integration test into build server since it involves interaction between several components which most likely developed by several developers.
thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

Ideally, if a fleet of flying saucers from Omicron Perseii 8 were to descend on the primary development site and vaporize it, but a backup site existed with source archives, build tools and Jenkins, you should be able to continue to build reliable deployables under the control of a single operator until a new development team was assembled.

Unit tests are not intended to simply aid the developer. They are intended to ensure that when a unit is changed that it will continue to operate as expected and that nothing gets deployed that doesn't operate as expected. Jenkins wouldn't usually do the unit tests directly, as a well-designed Ant or Maven project already has them integrated into the project component build process. One of the things I do with unit testing is verify that none of my persistence modules has broken SQL in it, since SQL isn't syntax-checked at java compile time.

Yes, Jenkins does make sense for integration testing, however.

Jenkins also is more than just a framework for managing a single project, though. It can do builds for an entire shop's worth of projects and ensure that dependent projects are rebuilt when dependencies are rebuilt whether the dependencies are sub-projects or independent projects in their own right.

Jenkins can also take the results of builds and deploy them into production, although that's not one of its primary purposes. It often does deploy to QA test servers, though.

One of the most highly-touted features of Jenkins is its ability to do nightly builds for large projects with many contributors. A lot of people I know (myself included) aren't sure that simply shoving a day's work out every day is that wonderful. I'm rough on my toys and often rip up stuff so badly it takes most of a week to compile clean again. But there are people that like the nightly approach. And I do like the idea that I can check in a branch and trigger a beta build, for example.



David Spades
Ranch Hand

Joined: Feb 01, 2014
Posts: 201
so, does that mean the best practice for integration test is to separate them to a different eclipse project and jenkins should deploy them as separate build job? thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

Tim: That's a very specific problem. What if the flying saucers are from a different planet?

David: What are you using to actually do the build? Ant/Maven/other? I ask because Maven has very specific conventions.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

I see from another thread you are using Maven. Maven allows a variety of approaches as described here. Personally, I like having both unit and integration tests in the same project as the code. Maven runs them in two passes by naming convention so the unit tests run first. The reason I like this is that it doesn't create a jar if the integration tests fail.
David Spades
Ranch Hand

Joined: Feb 01, 2014
Posts: 201
okay, so, how do I configure jenkins to build only when there's a commit on repo?
I read in jenkins wiki about jenkins subversion api. how do I do this?
thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

You don't need to use the Subversion API directly. Jenkins has a Subversion plugin. You can configure it to poll SVN to see when there are changes and kick off a build. This blog post has good screenshots of how to set itup.
David Spades
Ranch Hand

Joined: Feb 01, 2014
Posts: 201
the blogpost was using uberSVN. If possible I want to avoid using more and more third party tools. Is this possible? thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

Sorry. I didn't read the blog post, just looked at the screenshots and said "that's what it looks like." The normal Subversion plugin for Jenkins looks like that - minus the UberSVN stuff.
David Spades
Ranch Hand

Joined: Feb 01, 2014
Posts: 201
I'm reading Jenkins The Definitife Guide page 101. On top of the page, it's recommended to put a script to Jenkins Subversion API. This is the issue I'm struggling with right now. Thanks.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

I think what you need is a post-commit hook set up in Subversion. See this: http://jenkins-ci.org/node/212


JBoss In Action
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

Peter Johnson wrote:I think what you need is a post-commit hook set up in Subversion. See this: http://jenkins-ci.org/node/212

What is the advantage of a hook over polling? Oh. The link describes that!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

One of our project teams actually uses the post-commit hook. You can easily recognize that project in the Jenkins home page because it is the one that is always building, constantly, all day long, over and over again That project has several times as many artifact versions in Nexus than any other project. Most of the rest of our projects just do a daily Subversion poll which seem sufficient. And if we really need the artifact RIGHT NOW, a manual build suffices.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Configure Jenkins to run a job on every commit in SVN repository