'where is Jenkins default maven-repository?
I have Jenkins ver.2.121.1 installed on Windows Server 2012 R2 along with Apache Maven 3.5.2.
In localhost:8080/systeminfo link, $MAVEN_HOME environment variable is set correctly (to C:\\apache-maven-3.5.2\) and maven saves my custom libraries in ~\.m2\.repository\ but Jenkins saves the custom libraries(like ojdbc, ...) in
another directory (in C:\\Program Files(x86)\Jenkins\maven-repositories\0\).
In jenkins config.xml (in C:\\Program Files(x86)\Jenkins\config.xml), no line is specified about maven local repositories (for example nothing is defined like <localRepository>${env.HOME}/.m2/repository</localRepository>).
Is there any clear reason why Jenkins uses its own maven repository directory? Should I addres my own maven directory to force jenkins give priority to it?
Solution 1:[1]
Solution 2:[2]
If using a Jenkinsfile configuration you may add Jenkins default repository to get artifacts when installing/compiling with maven. Like this:
script {
try {
sh 'mvn -Dmaven.repo.local=/data/jenkins/repository/ clean install'
} catch (errorDescription) {
// do whatever you need to notify error
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vikingsteve |
| Solution 2 | Enrique Cuchetti |

