Reputation: 5482
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/.../MyClass.java:[136,44] cannot find symbol
symbol: method setStore(java.util.UUID,java.util.UUID,java.util.Date,int)
location: variable _storeService of type com.my.module3.interfaces.StoreService
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:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>module3-${project.version}</finalName>
<artifactSet>
<includes>
<include>*:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.my.module3.App</Main-Class>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
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.
Upvotes: 3
Views: 7259
Reputation: 2881
I had this problem after moving jenkins folder to another drive. Confusingly, running maven manually from a cmd in the remote server worked fine, but failed when running from pipeline. Deleting .m2 didn't help. The cause was that before moving I did jenkins.exe uninstall
and then jenkins.exe install
to update windows service / jenkins home variable (I found this as a recommendation somewhere). The new service had configured to use system user, and so confusingly used .m2 located somewhere inside the C:/Windows directory. Going to services, and changing in properties dialog the user the service to run as solved it. Somewhat offtopic to OP, but I figure this may prove useful to others, since this question was the first promising thing I found when searching for my issue
Upvotes: 0
Reputation: 3972
You can choose the option "Delete Workspace before build starts" in Build Environment configuration.
This option is accessible after install "Workspace Cleanup Plugin"
Upvotes: 0
Reputation: 2601
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.
Upvotes: 4