Building multiple maven projects without a parent pom?

55 views
Skip to first unread message

Kristian Rink

unread,
Aug 22, 2016, 10:22:30 AM8/22/16
to Jenkins Users
Folks;

for my use case, I'd like to configure a setup / jenkins project that should work more or less like this:

* clone a defined set of maven modules from a local git server in a defined order into a set of named folders in the current jenkins projects workspace
* iterate over these folders and do a "mvn clean install" on each one of them (and make the build fail if any of these maven builds fail),
* run a shell script that takes the outcome of the last of these projects and launches it locally using either another shell script or a java -jar command (standalone dropwizard based service).

So far, I tried various approaches to resolve this and, all the time, failed. Browsing the web, I read that the most common way of doing this is to have a parent pom somewhere in version control which gets checked out and built - however this is something I'd ideally like to avoid.
Do you think such an approach is in some way possible? How, if so?

TIA and all the best,
Kristian

Baptiste Mathus

unread,
Aug 22, 2016, 7:44:05 PM8/22/16
to jenkins...@googlegroups.com

Not sure I get what you're trying to do, but using pipeline it'd probably be easy to write that logic you're expressing.

Cheers


--
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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3c75cb87-f9d3-4555-9311-154685b360b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kristian Rink

unread,
Aug 23, 2016, 2:02:06 AM8/23/16
to jenkins...@googlegroups.com
Am Dienstag, den 23.08.2016, 01:43 +0200 schrieb Baptiste Mathus:
> Not sure I get what you're trying to do, but using pipeline it'd
> probably be easy to write that logic you're expressing.


I'll have a look at pipelines then - thanks for your hint. Well, to
maybe explain a bit clearer what we're trying to achieve: 

We do have a couple of service applications in our environment that
include various local maven artifacts providing common core
functionalities (database access, authentication, ...). 

From a maven project point of view, they are pom "compile" scope
dependencies that could come from a central maven repository (and
actually they already do, for releases). That's also why the services
and the shared modules don't have a common parent / multi-module pom -
they logically don't belong to each other that much.

From a development process however, some of the stories our team is
working on include changes in several modules (say, the frontend layer,
some business logic, as well as even changes in the database model).
From a code versioning point of view they're separate projects living
in separated git repositories, in worst case living in tags or
subbranches.

What we basically want to do using jenkins is to automate the process
that, in order to deploy to our testing environment, for this work-in-
progress modules, someone needs to take all the relevant branches of
all the projects involved, build them in the right order, unzip the
final artifact to somewhere on the testing system and launch it. 

The most straightforward way of doing so (and, actually, the way we do
it right now) is to have a shell script that does...

- git clone and git checkout -b for all projects and branches to have
them as subfolders in a shared workspace structure like

 /database-api
 |   |
 |   /pom.xml
 |
 /auth
 |   |
 |   /pom.xml
 .
 .
 .
 /service
     |
     /pom.xml
 

- have a script run across this structure to do "mvn clean install" in
each of the subfolders

- have a script enter <service>/target and unzip whatever has been
built in there to somewhere on disk.


This might not be the best approach to building such structures but so
far it works; I'm more than open to better ideas how to solve the same
problem. ;)

Jesse McCormick

unread,
Aug 24, 2016, 8:19:44 PM8/24/16
to Jenkins Users

1) If this isn't available in pure git, you can just multi SCM plugin to retrieve from multiple git locations. Maybe helpful: http://stackoverflow.com/questions/9767919/in-jenkins-how-to-checkout-a-project-into-a-specific-directory-using-git
2. Just add multiple build steps in the order desired
3. Should be easy to script as a post build action.

Are you using an m2 project or freestyle project? Have you tried the above an it failed?
Reply all
Reply to author
Forward
0 new messages