Reputation: 33
I have a jenkins job for building my maven project(say project A) which has a dependency on a jar created by another local project(say project B). The jar is present in my local .m2 repo but Jenkins fails to find it in the local repo and goes to search it in central (https://repo.maven.apache.org/maven2) which obviously it will not find and hence my job fails. I have performed the below checks before posting this question here :
mvn clean install
, it builds successfully. So, Its only with Jenkins that I am not able to build the project.
Here is my POM for Project A
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.akamai</groupId>
<artifactId>cobra-tracer-api</artifactId>
<version>1.0.2</version>
<packaging>war</packaging>
<name>cobra-tracer</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>cobra-tracer</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
//some dependencies here
<dependency>
<groupId>com.akamai.aps</groupId>
<artifactId>logger-service</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
</project>
The POM for Project B is
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.akamai.aps</groupId>
<artifactId>logger-service</artifactId>
<version>0.0.3</version>
<packaging>jar</packaging>
<name>logger-service</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Upvotes: 3
Views: 20955
Reputation: 2272
The way you have integrated jenkins with maven is not correct. You have to use either artifactory or nexus, both of them have free versions that are sufficiently good to use. You build your project B and deploy them to above repository manager and your project A downloads it from repository manager.
For your specific problem, check
mvn install
. In your project 'A' run maven command using -U flag. mvn -U install
. mvn -s /home/jenkins/setting.xml install
. There is an option to define a different settings file in jenkins project configuration. Let me know how it goes.
Since you have added artifactory in your workflow now and facing plugin not found problem, add the following in your settings.xml
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>remote-repos</name>
<url>http://<artifactory-ip>:<artifactory-port>/artifactory/repo</url>
<id>remote-repos</id>
</mirror>
</mirrors>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://<artifactory-id>:<artifactory-port>/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://<artifactory-id>:<artifactory-port>/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
I am assuming that you have already added repository tag.
Upvotes: 2