Reputation: 11456
I have a project with a pom.xml that includes a simple dependency:
<dependency>
<groupId>com.somegroupid</groupId>
<artifactId>LocalProject</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
And when I run the project locally, everything works perfectly. But when I push the project to github and Jenkins tries to build it automatically, I get this error:
[WARNING] The POM for com.somegroupid:LocalProject:jar:1.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.563 s
[INFO] Finished at: 2017-08-26T13:19:47+02:00
[INFO] Final Memory: 9M/31M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MainProject: Could not resolve dependencies for project com.somegroupid:MainProject:war:1.0-SNAPSHOT: Could not find artifact com.somegroupid:LocalProject:jar:1.0-SNAPSHOT -> [Help 1]
My guess is that the project jar does not get included in the build and when jenkins tries to build it it looks for it in the central repository and effectively doesn't find it. (As is expected because the dependency is only available in my local repository)
How can I make sure the dependency gets included when building?
Upvotes: 1
Views: 1143
Reputation: 3256
when jenkins tries to build it looks for it in the central repository and effectively doesn't find it. (As is expected because the dependency is only available in my local repository)
You are right
As far I know you have two ways to solve this.
1 - Professional solution (better) Create a internal maven repository with artifactory(I use this) or nexus, and deploy jar, modules and dependencies in this repo. Configure your repository server to download dependencies from internet. Configure maven on Jenkins to use your local maven repository server instead of https://repo.maven.apache.org/maven2/ or other like.
This is a good solution if you work with a great team of developers, you can control what people are using and what version.
2 - Workaround
Just put your com.somegroupid:LocalProject:jar file inside the directory .m2/repository in jenkins server.
[Notice] Just use this solution if you are in a hurry and have few files as local dependencies
Upvotes: 1