詹金斯没有建立dockerfile

时间:2020-02-25 15:07:43

标签: docker jenkins jenkins-pipeline

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")

这是错误,这是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")
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

'def'给您带来麻烦,因为Jenkins文件会期望执行此步骤而不是常规命令。

这是我的操作方式:

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

其中$ {RegistryURL},$ {ProjectName},$ {ProjectVersion}是我在环境部分的文件上部定义的变量。

相关问题