2017-06-13 63 views
1

我有兩個問題。但是,也許我不知道如何爲這個問題添加標籤,以便爲兩者添加標籤。第一個問題與Jenkins插件使用相關,用於烘烤並使用this推送碼頭圖像。以下是我的Jenkinsfile腳本。我在目標目錄中完成了構建jar文件。然後我想運行這個docker插件來烘焙這件神器。正如你所知道的,我們需要有一個Dockerfile,所以我把它放在git克隆源代碼的根目錄下。我如何配置這個?我不知道如何做到這一點。如果我在下面跑,詹金斯告訴說沒有步驟。如何配置Jenkinsfile來構建泊塢窗圖像並將其推送到私人註冊表

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 這是另一個詹金斯管道語法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

您正在撰寫的.jar到/usr/myapp。這意味着/usr/myapp將是jar文件而不是目錄,導致該錯誤。將你的docker copy行改爲COPY ./target/spring-petclinic-1.5.1.jar /usr/myapp/(帶有斜線),你的Dockerfile應該可以工作。

相關問題