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 {
AWS_CREDENTIAL_NAME = "AWSCredentials"
REGION = "ap-northest-2"
REGION = "ap-northeast-2"
DOCKER_IMAGE_NAME = "std01-spring-petclinic"
ECR_REPOSITORY = "257307634175.dkr.ecr.ap-northeast-2.amazonaws.com"
ECR_DOCKER_IMAGE = "${ECR_REPOSITORY}/${DOCKER_IMAGE_NAME}"
@ -29,10 +29,11 @@ pipeline {
}
}
}
stage('Mvnen Build') {
stage('Maven Build') {
steps {
echo 'Maven Build'
sh 'mvn -Dmaven.test.failure.igmore=ture clean package'
sh 'mvn -Dmaven.test.failure.ignore=true clean package'
}
post {
success {
@ -41,7 +42,7 @@ pipeline {
}
}
stage ('Docker Image Build'){
stage ('Docker Image Build') {
steps {
echo 'Docker Image Build'
dir("${env.WORKSPACE}") {
@ -51,31 +52,35 @@ pipeline {
"""
}
}
}
stage ('Docker Image Build'){
stage ('Push Docker Image to ECR') {
steps {
echo "Push Docker Image to ECR"
script {
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()
}
}
}
}
stage('Clean Up Docker Images on Jenkins Server'){
steps {
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') {
}
}
}