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

View File

@@ -15,10 +15,10 @@ spec:
app: $APP_NAME app: $APP_NAME
spec: spec:
imagePullSecrets: imagePullSecrets:
- name: my-registry-key - name: aws-registry-key
containers: containers:
- name: $APP_NAME - name: $APP_NAME
image: nanajanashia/demo-app:$IMAGE_NAME image: $DOCKER_REPO:$IMAGE_NAME
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 8080 - containerPort: 8080