Update Jenkinsfile

This commit is contained in:
lwj9812 2024-03-15 15:34:46 +09:00 committed by GitHub
parent a200b45770
commit 7eb1014e7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

25
Jenkinsfile vendored
View file

@ -7,7 +7,7 @@ pipeline {
environment { environment {
AWS_CREDENTIAL_NAME = "AWSCredentials" AWS_CREDENTIAL_NAME = "AWSCredentials"
REGION = "ap-northest-2" REGION = "ap-northeast-2"
DOCKER_IMAGE_NAME = "std01-spring-petclinic" DOCKER_IMAGE_NAME = "std01-spring-petclinic"
ECR_REPOSITORY = "257307634175.dkr.ecr.ap-northeast-2.amazonaws.com" ECR_REPOSITORY = "257307634175.dkr.ecr.ap-northeast-2.amazonaws.com"
ECR_DOCKER_IMAGE = "${ECR_REPOSITORY}/${DOCKER_IMAGE_NAME}" ECR_DOCKER_IMAGE = "${ECR_REPOSITORY}/${DOCKER_IMAGE_NAME}"
@ -29,10 +29,11 @@ pipeline {
} }
} }
} }
stage('Mvnen Build') {
stage('Maven Build') {
steps { steps {
echo 'Maven Build' echo 'Maven Build'
sh 'mvn -Dmaven.test.failure.igmore=ture clean package' sh 'mvn -Dmaven.test.failure.ignore=true clean package'
} }
post { post {
success { success {
@ -41,7 +42,7 @@ pipeline {
} }
} }
stage ('Docker Image Build'){ stage ('Docker Image Build') {
steps { steps {
echo 'Docker Image Build' echo 'Docker Image Build'
dir("${env.WORKSPACE}") { dir("${env.WORKSPACE}") {
@ -51,31 +52,35 @@ pipeline {
""" """
} }
} }
} }
stage ('Docker Image Build'){ stage ('Push Docker Image to ECR') {
steps { steps {
echo "Push Docker Image to ECR" echo "Push Docker Image to ECR"
script { script {
sh 'rm -f ~/.dockercfg~/.docker/config.json || true' sh 'rm -f ~/.dockercfg~/.docker/config.json || true'
docker.withRegistry("http://${ECR_REPOSITORY}", "ecr"${REGION}:${AWS_CREDENTIAL_NAME}") { docker.withRegistry("http://${ECR_REPOSITORY}", "ecr:${REGION}:${AWS_CREDENTIAL_NAME}") {
docker.image("${ECR_DOCKER_IMAGE}:latest").push() docker.image("${ECR_DOCKER_IMAGE}:latest").push()
} }
} }
} }
}
stage('Clean Up Docker Images on Jenkins Server'){ stage('Clean Up Docker Images on Jenkins Server'){
steps { steps {
echo 'Cleaning up unused Docker images on Jenkins server' echo 'Cleaning up unused Docker images on Jenkins server'
sh "docker image prune -f --all --filter \"nutil=1h\"" sh "docker image prune -f --all --filter \"until=1h\""
} }
} }
stage('Upload to S3'){
stage('Upload to S3') {
} }
stage('Codedeploy Workload'){
stage('Codedeploy Workload') {
} }
} }
} }