Skip to content

Maven build fails ONLY when run with jenkins

I have a Java project that is committed to GitHub. The project consists of 3 modules. I have configured the Jenkins Workflow Multibranch Pipeline plugin to build the 3 modules.

node {
   // Mark the code checkout 'stage'....
  // stage 'Checkout'

   // Get some code from a GitHub repository
   git url: '[email protected]:me/myproject.git', credentialsId: '###'

   // Get the maven tool.
   // ** NOTE: This 'M3' maven tool must be configured
   // **       in the global configuration.
   def mvnHome = tool 'M3'

   stage 'Build module 1'
   sh "${mvnHome}/bin/mvn -f module-1/ clean install"

   stage 'Build module 2'
   sh "${mvnHome}/bin/mvn -f module-2/ clean install"

   stage 'Build module 3'
   sh "${mvnHome}/bin/mvn -f module-3/ clean install"

Maven builds the first 2 modules with no problem. But on the third module I get the following error:

 Compilation failure
/var/lib/jenkins/workspace/.../[136,44] cannot find symbol
  symbol:   method setStore(java.util.UUID,java.util.UUID,java.util.Date,int)
  location: variable _storeService of type

I have red that there may be a problem with the version of maven-compiler-plugin so I updated it to the latest 3.5.1 version, but it did not help.

These are the maven plugins that I use in all 3 of the modules:

                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

When I build the module in IntelliJ there are no errors. I even pulled the repository in a new folder and used the mvn clean install command for the module3 and it finishes without a problem.

I have no idea where the problem is. It does not seem that there is something wrong with my code, as it works correctly (I have debugged it). Any help or suggestions would be greatly appreciated.


Try removing .m2 folder from your jenkins server. That way jenkins will trigger downloading of all your dependencies and you well get new version. Actually problem you have encountered is quite common.