Skip to content

Instantly share code, notes, and snippets.

@emeraldhieu
Created March 12, 2020 04:31
Show Gist options
  • Save emeraldhieu/e6fd24ccc335f7de6aa8884f28cceb5e to your computer and use it in GitHub Desktop.
Save emeraldhieu/e6fd24ccc335f7de6aa8884f28cceb5e to your computer and use it in GitHub Desktop.
stage('Build docker') {
steps {
script {
def imageTag = dockerImage.getImageTag("${BRANCH_NAME}", "${REVISION}");
docker.build("${PROJECT_NAME}" + ":" + imageTag)
}
}
}
stage('Push docker') {
when {
anyOf {
branch 'develop' // for development
branch 'release/**' // for release
}
}
steps {
script {
docker.withRegistry("${DOCKER_REGISTRY_URI}", "${DOCKER_REGISTRY_LOGIN}") {
def imageTag = dockerImage.getImageTag("${BRANCH_NAME}", "${REVISION}");
def image = docker.image("${PROJECT_NAME}")
echo "Pushing image tag ${imageTag}..."
image.push(imageTag);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment