Running Jenkins integration test without having to rebuild with Maven

I have some trouble understanding how Jenkins interacts with Maven to create simple pipleines assemblies. For example, let's say I want to make the following pipeline:

1 Compile code, run unittest, and package to code.
2 Deploy application to test server.
3 Run integration tests.

      

This will translate to:

1 mvh clean install
2 deploy.sh
3 mvn verify

      

For my unittests I am using surefire and for the integration test I am using failover. However, the problem is that it mvn verify

will run the whole build process over and over. I only want to do integration tests, not all the steps that need to be verified. What is the standard way to deal with this problem?

+3


source to share


1 answer


For this you need to do everything using maven. The default maven build lifecycle has a phase for each of the steps you want to follow: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

For example, the default lifecycle includes the following phases (for a complete list of lifecycle phases, see Lifecycle Reference):

validate - check the correctness of the project and all the necessary information is available

compile - compile the source code of the project

test - check the compiled source code with a suitable block. These tests should not require the code to be packaged or deployed

- take the compiled code and package it in your redistributable format such as JAR.

integration-test - process and optionally deploy the package to an environment where integration tests can run

Check - Perform all checks to ensure the package is valid and meets the quality criteria

install - install the package to the local repository, for use as a dependency in other projects locally

Deployment - done in an integration or release environment, copies the final package to a remote repository for sharing with other developers and projects.

So, you want to deploy the artifacts to the test server (your step 2) as part of the integration-test phase. Then all you have to do is run



mvn clean install

      

This will clean and then do whatever you build, run unit tests, package everything, deploy to the integration environment, run your integration tests, and install the artifacts in your local repository.

+1


source







All Articles