docker 使用 jenkins 问题构建

docker build with jenkins issue

我正在尝试编写一个管道,它首先克隆一个存储库,然后构建一个 docker 图像,然后将 docker 图像推送到 docker 集线器。以下是我的詹金斯文件。

pipeline {
    agent { dockerfile true }
    environment {
        APPLICATION = 'connect'
        ENVIRONMENT = 'dev'
        BUILD_VERSION = '0.9.5'
        MAINTAINER_NAME = 'Shoaib'
        MAINTAINER_EMAIL = 'shoaib@email.com'
        BUILD_DOCKER_REPO = repo1/images'
        DOCKER_IMAGE_TAG = 'repo1/images:connect_dev_0.9.5'
    }
    stages {
        stage('clone repository') {
            steps {
                checkout Jenkins-Integration
            }
        }
        stage('Build Image') {
            steps {
                image = docker.build("-f Dockerfile.local", "--no-cache", "-t ${DOCKER_IMAGE_TAG}", "--build-arg envior=${ENVIRONMENT} .", "--build-arg build_version=${BUILD_VERSION} .", "--build-arg maintainer_name=${MAINTAINER_NAME} .", "--build-arg maintainaer_email=${MAINTAINER_EMAIL} .")
            }
        }
        stage('Deploy') {
            steps {
                script {
                    docker.withRegistry('https://registry.example.com', 'docker-hub-credentials') {
                        image.push(${DOCKER_IMAGE_TAG})
                    }
                }
            }
        }
    }
}

但是当我 运行 在蓝海中从事这项工作时,我遇到了以下错误。

我试过谷歌搜索但找不到满意的答案。任何帮助表示赞赏。

将下面阶段的docker.build放入script如下:

   stage('Build Image') {
        steps {
           script {
            def image = docker.build("-f Dockerfile.local", "--no-cache", "-t ${DOCKER_IMAGE_TAG}", "--build-arg envior=${ENVIRONMENT}", "--build-arg build_version=${BUILD_VERSION}", "--build-arg maintainer_name=${MAINTAINER_NAME}", "--build-arg maintainaer_email=${MAINTAINER_EMAIL} .")
           }
        }
    }