Reputation: 1216
I have a Jenkins instance running builds of multiple microservices and libraries.
Currently, I have my build configured in a way that all the jobs use different local repository locations $WORKSPACE/.m2/repository
.
This is good because the builds have no way of influencing each other, however, builds obviously tend to be a lot longer, because they need to download all the dependencies every single time.
What do you think is the better solution? Shall I keep the current configuration, or is it safe enough to use the same local repo location for all the jobs?
Is there a way to ensure that builds can't influence each other, even though the local repo is the same?
What comes to my mind is I could configure the project so that all SNAPSHOTs are updated every time. Is this enough? How can I do it from my settings.xml
?
I got some questions in comments and I think answering them here is better, so:
Why do I delete my repository folder before each build?
Because the repo is in the jenkins job folder (currently). I clean the job folder, because I sometimes need to modify the pom during build. (Change version for a release).
Do you have many branches? Do you use a repository manager?
Yes, I do.
How many jenkins nodes do you have?
Currently only one, but this might change in the future.
How do you build on Jenkins (meaning) which exact maven execution command do you use in Jenkins?
I use mvn clean deploy
, with some additional properties
Upvotes: 0
Views: 862
Reputation: 35785
Whatever you do, make sure that one local repository is not used by more than one build at a time. The local repository is not safe for concurrent use. You easily break the metadata if two builds try to update the same SNAPSHOT.
Upvotes: 1
Reputation: 1216
My current solution is that I made a directory outside of jenkins home, /maven/.m2/repository/
. But this is not the local repository itself.
The actual repository is: <localRepository>/maven/.m2/repository/${env.JOB_NAME}</localRepository>
. This way, I get a different repo for every job, but it doesn't get deleted when the workspace gets deleted for the job.
Upvotes: 0