add ecr repo stage
This commit is contained in:
12
Jenkinsfile
vendored
12
Jenkinsfile
vendored
@@ -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}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user