1

Currently I am working in a project that integrates Gitlab + Jenkins + Maven.

This is a Maven Java project and we have UT and Integration tests.

I designed a pipeline for the CI that looks like this:

  1. Build Core Package and Run UT
  2. Build WebPage and Run UT
  3. Run Integration Tests written in Cucumber.
  4. Deploy to a staging Server

On paper this looks good but now I am trying to implement this and I am having some issues.

  • Is there a simple way to save the java packages in per Git Branch? Each branch will compile and create a Jar file in step 1 that will be needed in Step 2.
  • In step 3 how can I use the war built in step 2 to run the tests? Currently I have all inside the lifecycle of Maven, but cannot find a way to split this.

Thanks

jpereira
  • 251
  • 2
  • 11

2 Answers2

1

You can use jenkins to perform this job

  • That is the Idea, but I am stuck in the 2 issues I pointed out – jpereira Oct 20 '15 at 15:27
  • You can achieve this by checking the "Permission to copy Artifact" option and mentioning the name of second Jenkins job where you wants to use the war or jar generated by first jenkins job. Then finally in second jenkins job under Build tab select the Copy artifacts from another project and specify the path from where(Ex: If it is in same git repository /folder1/folder2/jarName.jar) war or jar is available. – user3604037 Oct 27 '15 at 09:37
0

I don't think you want to be putting build assets into source control. You should be able to use Jenkins to run the individual steps of your maven build and use the intermediate jar and war files that it creates in its working directory. If you can't split them out into separate steps within maven for some reason, you may need to simply do the whole maven build and then run the tests with the working files which it shouldn't remove.

piemonkey
  • 741
  • 3
  • 6
  • I am not going to save Jars or Wars in Git. I need to generate build per branch. The problems that I have is in the implementation of this. Because I want to split things into different tasks and not have the tasks redoing things that were already done in previous tasks – jpereira Oct 20 '15 at 15:28
  • Ah, I misunderstood, now I get the question. Do you mean you need to run step 1. and then step 2. for each branch or that you run step 1. for each branch and then somehow use all of them for step 2? I'm guessing the first one? – piemonkey Oct 20 '15 at 16:58
  • Branch A as a change, it will trigger step 1 then step 1 trigger Step 2 then step 3 then step 4 – jpereira Oct 20 '15 at 18:33
  • You'll need to set up Jenkins to [trigger a build on a push](https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin) to gitlab. Then since maven will run all the phases in a lifecycle, if you want to it only once you'll need to run the whole build and then do your tests afterwards using the jars and wars that it creates. You can get your second question to work but it apparently involves [defining your own lifecycle](https://stackoverflow.com/a/12468235/5363156). – piemonkey Oct 20 '15 at 23:07