Reputation: 1416
I am having trouble packaging a maven module on Jenkins. This problem does not occur when I package the module locally. I have a module which for the sake of this post can be referred to as moduleA. I also have a common module which contains objects that are used by moduleA and moduleB. This module's name is common. I have a dependency listing for common in the moduleA pom.xml. The project also contains dependencies taken from our private nexus repository. The problem that is occurring, is that when maven is downloading all the dependencies on Jenkins, it is looking for common on the Nexus repo. Below is some relevant information. Is there a way I can resolve this, short of deploying the common module to the Nexus?
Maven Command
mvn -pl sub_module_name package -X -U --also-make-dependents
Repositories in POM
<repository>
<id>nexus-snapshots</id>
<url>${our.nexus.instance}</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>nexus-releases</id>
<url>${our.nexus.instance}</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
Jenkins Error Message
[ERROR] Failed to execute goal on project moduleA: Could not resolve
dependencies for project my.artifact:moduleA:jar:1.0.01-
SNAPSHOT: Could not find artifact my.artifact:common:jar:1.0.01-
SNAPSHOT in nexus-snapshots
({our.nexus.instance}) ->
[Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal on project moduleA: Could not resolve dependencies for project
my.artifact:moduleA:jar:1.0.01-SNAPSHOT: Could not find
artifact my.artifact:common:jar:1.0.01-SNAPSHOT in nexus-
snapshots ({our.nexus.instance})
Upvotes: 1
Views: 330
Reputation: 36
I believe the problem is in your maven command. I recommend you change your command to the following
mvn -pl common,moduleA install package -X -U
This ensures that the common module is installed before moduleA is packaged.
Upvotes: 2