Force Jenkins to get from remote repository

I have two build jobs for the same project in different branches - Live and Dev The pom files are identical in both, and I use profiles to add a different remote repository that stores the dependencies for each branch. For example an artifact core-SNAPSHOT.jar exists in both repositories.

I have a problem whereby if the Dev branch project was built, and the Dev core-SNAPSHOT.jar had been updated, it will be downloaded from the Dev repository and stored in the local repository. Then if the Live branch project was built, it would use the local core-SNAPSHOT.jar since this would be newer than the latest one in the Live repository. Since the core dependency is a SNAPSHOT release, should it not be downloading it again every time the project builds?

Is there a way to either tell a jenkins build job to force download specific dependencies everytime it builds, or create 2 separate local repositories and point the relevant build jobs to each? Having job specific repositories is not really ideal as we have around 20 projects in Dev and Live, all sharing the same dependents.

Thanks, Damian

Answers


Looks like I've figured it out myself.

For anybody who might be interested. I created separate directories on my Jenkins server and I've configured my build jobs to use a different local repository depending on the branch. In the Jenkins build 'Goals and Options', I added

-Dmaven.repo.local=/var/lib/jenkins/repositories/{branchSpecificRepository}/

This means if I update anything in the Dev branch, it will pull down the latest Dev dependencies, and if I later build the Live projects they will continue to use the older dependency projects.


Need Your Help