我正在尝试设置jenkins CI / CD管道,并且要构建的项目导致构建错误:
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project kafka: Could not resolve dependencies for project
kafka:kafka:jar:0.0.1-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.8.0_212 at specified
path /opt/java/openjdk/lib/tools.jar -
试图了解为什么它不能解决这种依赖性。 jdk在pom文件中列出,我也在jenkins文件中指定。
node
{
def scmVars = checkout scm
def commitHash = scmVars.GIT_COMMIT
sh "echo githubcommithash is $commitHash"
sh "echo $WORKSPACE"
docker.image('adoptopenjdk/maven-openjdk8:latest').inside('-v $HOME/.m2:/root/.m2')
{
stage('Build')
{
sh 'mvn clean install package -Dmaven.test.skip=true'
sh 'pwd'
}
}
stage('Deploy')
{
withEnv(["DOCKER_HOST=tcp://192.xxx.xxx.xxx:2375"])
{
docker.withRegistry('https://jenkins-docker-repo.net')
{
def customImage = docker.build("sample:${commitHash}", "-f Dockerfile .")
customImage.push("latest")
sh "docker pull jenkins-docker-repo.net/sample:latest"
sh "docker stop sample || true && docker rm sample || true"
sh "docker run -d --restart=always --name=sample -p 10020:10020 -v /tmp/caprod:/tmp/caprod jenkins-docker-repo.net/sample:latest"
}
}
}
}
Pom文件:
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.8.0_212</version>
<scope>system</scope>
<systemPath>${java.home}/lib/tools.jar</systemPath>
</dependency
我最初有任何建议,或者有人可以在这里解释我需要做什么?