我有两个问题。但也许我不知道如何为这个问题添加标签,以便我为两者添加标签。第一个问题与使用this烘焙和推送泊坞窗图像的Jenkins插件使用有关。下面是我的Jenkinsfile脚本。我在目标目录中完成了jar文件的构建。然后我想运行这个docker插件来烘焙这个神器。如您所知,我们需要一个Dockerfile,因此我将它放在git克隆源的根目录中。我如何配置?我不知道怎么回事。如果我跑到下面,詹金斯告诉说没有步骤。
pipeline {
agent any
stages {
stage('build') {
steps {
git branch: 'master', credentialsId: 'e.joe-gitlab', url: 'http://70.121.224.108/gitlab/cicd/spring-petclinic.git'
sh 'mvn clean package'
}
}
stage('verify') {
steps {
sh 'ls -alF target'
}
}
stage('build-docker-image') {
steps {
docker.withRegistry('https://sds.redii.net/', 'redii-e.joe') {
def app = docker.build("sds.redii.net/e-joe/spring-pet-clinic-demo:v1",'.')
app.push()
}
}
}
}
}
UPDATE 这是另一个Jenkins Pipeline Syntax sniffet生成器。但它也不起作用。
pipeline {
agent any
stages {
stage('build') {
steps {
git branch: 'master', credentialsId: 'e.joe-gitlab', url: 'http://70.121.224.108/gitlab/cicd/spring-petclinic.git'
sh 'mvn clean package'
}
}
stage('verify') {
steps {
sh 'ls -alF target'
}
}
stage('docker') {
withDockerRegistry([credentialsId: 'redii-e.joe', url: 'https://sds.redii.net']) {
def app = docker.build("sds.redii.net/e-joe/spring-pet-clinic-demo:v1",'.')
app.push()
}
}
}
}
Dokerfile如下所示。如果我尝试在我的本地烘焙图像,我收到以下错误。
container_linux.go:247: starting container process caused "chdir to cwd (\"/usr/myapp\") set in config.json failed: not a directory"
oci runtime error: container_linux.go:247: starting container process caused "chdir to cwd (\"/usr/myapp\") set in config.json failed: not a directory"
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
DockerFile
FROM openjdk:7
COPY ./target/spring-petclinic-1.5.1.jar /usr/myapp
WORKDIR /usr/myapp
RUN java spring-petclinic-1.5.1.jar
答案 0 :(得分:1)
您正在将.jar写入/usr/myapp
。这意味着/usr/myapp
将是jar文件而不是目录,从而导致该错误。将docker copy行更改为COPY ./target/spring-petclinic-1.5.1.jar /usr/myapp/
(使用斜杠),Dockerfile应该可以正常工作。