Skip to content

Commit

Permalink
Merge pull request #35 from reportportal/5.7.3
Browse files Browse the repository at this point in the history
Update Jenkinsfile-candidate
  • Loading branch information
miracle8484 authored Nov 10, 2022
2 parents 2faf8b1 + cc3e6dd commit 40e2579
Showing 1 changed file with 44 additions and 28 deletions.
72 changes: 44 additions & 28 deletions Jenkinsfile-candidate
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'
}
}
}
}

0 comments on commit 40e2579

Please sign in to comment.