I have two maven Projects call them as MainProject and DependnecyProject. I use DependnecyProject functions in the MainProject project which means DependnecyProject is a dependency for MainProject Project.
MainProject pom.xml
<dependency>
<groupId>testgroup</groupId>
<artifactId>DependnecyProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
In my local eclipse, this is completely perfect and the execution doesn't have any problem.
I have both of these Projects in Git and I have two Jobs created in Jenkins named Main and Dependency. I have a Pre Step in the Main job to build the Dependency first and then build Main.
Dependency job is successful but the Main job is failing saying the dependency mentioned above (DependnecyProject) cannot be resolved. This can be understood as the Jenkins and Maven is not able to find the dependency. Is there a way to make sure the Jenkins resolve the dependency?
Alternately, I have tried one more solution In My Local, I have tried to use in MainProject POM.XML
<dependency>
<groupId>testgroup</groupId>
<artifactId>DependnecyProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>C:\Users\cpratap\New-Workspace\Child\target\Parent-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
which is working perfectly in local, but not sure how to make it work the same in the Jenkins?
Update: In the Jenkins Main job, I did below configuration (as suggested by @Ian W). Though it is a poor work around as mentioned, this really worked.
- Followed the same configuration
- In the Main Jenkins job, I have three Pre-Steps
- One Pre-Step is to trigger the Dependency Job
- Second Pre-Step is to copy the artifacts from Dependency to Main
- Third Pre-Step is to install the Dependency into the local repo using "Invoke Top Level Maven Targets" and used below in Goal install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging=jar
This completely solved my problem and I could run the build and run my test cases without any issues. Thank you all for the support