我正在尝试编写一个管道,它首先克隆一个存储库,然后构建一个 docker 映像,然后将 docker 映像推送到 docker hub。以下是我的詹金斯文件。
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})
}
}
}
}
}
}
我试过用谷歌搜索,但找不到满意的答案。任何帮助表示赞赏。