add ecr repo stage

This commit is contained in:
Nana Janashia
2020-12-05 16:53:33 +01:00
parent 8c32984bfa
commit 70fb6f1f11
2 changed files with 10 additions and 6 deletions

12
Jenkinsfile vendored
View File

@@ -5,6 +5,10 @@ pipeline {
tools {
maven 'Maven'
}
environment {
DOCKER_REPO_SERVER = '664574038682.dkr.ecr.eu-west-3.amazonaws.com'
DOCKER_REPO = "${DOCKER_REPO_SERVER}/java-maven-app"
}
stages {
stage('increment version') {
steps {
@@ -31,10 +35,10 @@ pipeline {
steps {
script {
echo "building the docker image..."
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh "docker build -t nanajanashia/demo-app:${IMAGE_NAME} ."
sh "echo $PASS | docker login -u $USER --password-stdin"
sh "docker push nanajanashia/demo-app:${IMAGE_NAME}"
withCredentials([usernamePassword(credentialsId: 'ecr-credentials', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh "docker build -t ${DOCKER_REPO}:${IMAGE_NAME} ."
sh "echo $PASS | docker login -u $USER --password-stdin ${DOCKER_REPO_SERVER}"
sh "docker push ${DOCKER_REPO}:${IMAGE_NAME}"
}
}
}