-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from reportportal/5.7.3
Update Jenkinsfile-candidate
- Loading branch information
Showing
1 changed file
with
44 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,56 @@ | ||
#!groovy | ||
properties([ | ||
parameters ([ | ||
string( | ||
name: "VERSION", | ||
defaultValue: "", | ||
description: "Release candidate version tag" | ||
), | ||
string( | ||
name: "BRANCH", | ||
defaultValue: "", | ||
description: "Specify the GitHub branch from which the image will be built" | ||
) | ||
]) | ||
]) | ||
|
||
node { | ||
|
||
load "$JENKINS_HOME/jobvars.env" | ||
load "$JENKINS_HOME/jobvars.env" | ||
|
||
dir('src/github.com/reportportal/service-index') { | ||
dir('src/github.com/reportportal/service-index') { | ||
|
||
stage('Checkout') { | ||
checkout scm | ||
stage('Checkout') { | ||
checkout scm | ||
} | ||
|
||
stage('Build Docker Image') { | ||
withEnv(["VERSION=${VERSION}", "AWS_URI=${AWS_URI}"]) { | ||
sh 'make IMAGE_NAME=${AWS_URI}/service-index build-image v=${VERSION}-RC-$BUILD_NUMBER' | ||
sh 'docker image tag ${AWS_URI}/service-index:latest ${AWS_URI}/service-index:${VERSION}-RC-$BUILD_NUMBER' | ||
} | ||
} | ||
|
||
stage('Push to ECR') { | ||
withEnv(["AWS_URI=${AWS_URI}", "AWS_REGION=${AWS_REGION}", "VERSION=${VERSION}"]) { | ||
def image = env.AWS_URI + '/service-index:' + env.VERSION + '-RC-' + env.BUILD_NUMBER | ||
def url = 'https://' + env.AWS_URI | ||
def credentials = 'ecr:' + env.AWS_REGION + ':aws_credentials' | ||
|
||
docker.withServer("$DOCKER_HOST") { | ||
stage('Build Docker Image') { | ||
withEnv(["AWS_URI=${AWS_URI}", "VERSION=${VERSION}"]) { | ||
sh "make IMAGE_NAME=${AWS_URI}/service-index build-image v=${VERSION}-RC-${env.BUILD_NUMBER}" | ||
} | ||
} | ||
stage('Push to ECR') { | ||
withEnv(["AWS_URI=${AWS_URI}", "AWS_REGION=${AWS_REGION}", "VERSION=${VERSION}"]) { | ||
def image = env.AWS_URI + '/service-index' | ||
def url = 'https://' + env.AWS_URI | ||
def credentials = 'ecr:' + env.AWS_REGION + ':aws_credentials' | ||
docker.withRegistry(url, credentials) { | ||
docker.image(image).push('${VERSION}-RC-${BUILD_NUMBER}') | ||
} | ||
} | ||
} | ||
stage('Cleanup') { | ||
docker.withServer("$DOCKER_HOST") { | ||
withEnv(["AWS_URI=${AWS_URI}"]) { | ||
sh 'docker rmi ${AWS_URI}/service-index:${VERSION}-RC-${BUILD_NUMBER}' | ||
sh 'docker rmi ${AWS_URI}/service-index:latest' | ||
} | ||
} | ||
} | ||
|
||
|
||
docker.withRegistry(url, credentials) { | ||
docker.image(image).push() | ||
} | ||
} | ||
} | ||
|
||
stage('Cleanup') { | ||
withEnv(["AWS_URI=${AWS_URI}"]) { | ||
sh 'docker rmi ${AWS_URI}/service-index:${VERSION}-RC-${BUILD_NUMBER}' | ||
sh 'docker rmi ${AWS_URI}/service-index:latest' | ||
} | ||
} | ||
} | ||
} | ||
|