I have a script in Java, I could run it with maven commands locally and even in the local Jenkins setup (localhost)
Same set of scripts when I try to run from company jenkins server, it throws an error as this :
- [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: unknown error: Unknown host repo.maven.apache.org: unknown error -> [Help 1] [ERROR]*
Note : I setup the jenkins server from ansible playbook, and the pipeline script is as follows:
node {
def mvnHome
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git branch: '*/work', credentialsId: 'git-deploy', url:'<correct git url>'
}
stage('Build') {
// Run the maven build
docker.image("maven:3.2-jdk-8").inside("--privileged=true -e TZ=Asia/Singapore") {
sh 'mvn --version'
sh 'which mvn'
sh "'/usr/bin/mvn' clean test"
}
}
What could be the cause? please help.
curl -L https://repo.maven.apache.org/maven2
to follow the redirect. As @anil mentions in his answer, there's possibly a proxy between your server and Maven central that is causing the issue. - noelob