每次Maven Java项目成功构建后,我都试图让Jenkins构建并发布项目的docker映像。
我在项目的根目录下有一个Dockerfile和一个Jenkinsfile。
这是我的Jenkins文件?
pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
options {
skipStagesAfterUnstable()
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
stage('Build image') {
steps {
script {
docker.withRegistry('http://localhost:5000') {
def customImage = docker.build("my-image:${env.BUILD_ID}")
customImage.push()
}
}
}
}
}
post {
always {
archiveArtifacts artifacts: 'target/**/*.jar', fingerprint: true
}
}
}
Jenkins tr构建此项目时,它返回给定的错误消息:
+ docker build -t my-image:13 .
/var/jenkins_home/workspace/powertiss-eureka_master@tmp/durable-b9e45059/script.sh: line 1: docker: not found
我在这里做什么错了?
* edit:我的Dockerfile
FROM openjdk:8-jdk-alpine
VOLUME /tmp
COPY target/projectName-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]