简体   繁体   English

詹金斯没有建立 dockerfile

[英]Jenkins not building dockerfile

jenkins doesn't like my docker build am I forgetting something specifically I am getting this. jenkins 不喜欢我的 docker build 是不是我忘记了一些特别的东西我得到了这个。

Started by user admin
Obtained Jenkinsfile from git http://gitlab.operasolutions.com/procurement-ai/procurement-ai-ui.git
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 17: Expected a step @ line 17, column 17.
                   def app = docker.build("procurementai-ui")

this is the error and this is the jenkinsfile这是错误,这是詹金斯文件

pipeline {
    agent any
    stages {
        stage('build') {
            steps {
                sh 'echo build'
            }
        }
        stage('verify') {
            steps {
                sh 'ls -alF target'
            }
        }        
        stage('docker') {
            steps{
                sh 'cd /home/jenkins/agent/workspace/procurementai-ui'
                def app = docker.build("procurementai-ui")
            }
        }
    }
}

'def' is causing you troubles as Jenkins file would expect a step not a groovy command. 'def' 给你带来了麻烦,因为 Jenkins 文件需要一个步骤而不是一个常规命令。

Here is how I did this:这是我如何做到的:

stage('Build Docker Image') {
      steps{
        script {
          dockerImage = docker.build "${RegistryURL}/${ProjectName}:${ProjectVersion}"
        }
      }
    }

where ${RegistryURL}, ${ProjectName}, ${ProjectVersion} are variables I defined in the upper part of the file in the environment section.其中 ${RegistryURL}、${ProjectName}、${ProjectVersion} 是我在环境部分文件上部定义的变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM