Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organize full build pipeline with Gulp, Maven and Jenkins, all the way to integration tests?

I have a project that has:

  • JS client with somewhat interesting build process. That includes compiling CSS, catenating and minifying JS and CSS, generating and processing HTML, and some other steps. The Node tools like Grunt or Gulp are great at this.
  • Java server that is a WAR deployed on Tomcat. It includes these assets as well as all the Java code. It has all kinds of tests: Unit tests, integration tests that may instantiate a DAO and talk to DB, and end-to-end API tests that actually talk to the app running on Tomcat.
  • End-to-end tests with Protractor. If you're not familiar, it's another Node tool that wraps Selenium.

How can I organize this whole process in a sane, robust, and automated way?

What I have at the moment is Gulp and Maven, with Maven basically owning the whole process.

  1. It calls Gulp asset generation in generate-sources using antrun (doh, third build tool!).
  2. It runs the regular Java build.
  3. It starts Tomcat with my WAR in pre-integration-test.
  4. It runs Java E2E tests talking to that tomcat with failsafe plugin.
  5. It calls Gulp again with antrun, this time to run Protractor tests.
  6. It shuts down Tomcat in post-integration-test.
  7. It's supposed to verify test results in verify.

That kind of works, except for that Maven is generally very rigid and I feel I'm taking it too far. Using antrun to call Gulp is an ugly trick. It's very hard to control dependencies between these steps and monitor their outcomes. It's hard to control order of things in the same phase. Failsafe verify does not seem to process the external JUnit report files that Gulp generates. I could go on.

I wonder if I should do more in my build server (Jenkins), maybe using a build pipeline or parameterized triggers - but I've never done it and I'm not sure if that's really better.

So, how would you implement it?

like image 778
Konrad Garus Avatar asked Sep 16 '14 09:09

Konrad Garus


1 Answers

In my experience, the frontend maven plugin is far and away the best plugin for this type of build/deploy process. https://github.com/eirslett/frontend-maven-plugin . This is how i use it for Grunt but it supports Gulp just as well.

<plugin>     <groupId>com.github.eirslett</groupId>     <artifactId>frontend-maven-plugin</artifactId>     <version>...</version>      <!-- optional -->     <configuration>         <workingDirectory>src/main/frontend</workingDirectory>     </configuration>     <execution>     <id>grunt build</id>     <goals>         <goal>grunt</goal>     </goals>      <!-- optional: the default phase is "generate-resources" -->     <phase>generate-resources</phase>      <configuration>         <!-- optional: if not specified, it will run Grunt's default         task (and you can remove this whole <configuration> section.) -->         <arguments>build</arguments>     </configuration> </execution> </plugin> 

One thing to be aware of it is will download node for the system it is being run on, so if you have a different OS on your build server, you'll need to make sure that is the version you have checked into version control, your local version (for me OSX) will have to be maintained local to your project.

like image 74
am80l Avatar answered Oct 08 '22 13:10

am80l