Update Jenkinsfile

This commit is contained in:
lwj9812 2024-03-22 11:45:56 +09:00 committed by GitHub
parent 568bde0658
commit c407c5041e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

11
Jenkinsfile vendored
View file

@ -6,11 +6,9 @@ pipeline {
}
environment {
AWS_CREDENTIAL_NAME = "AWSCredentials"
REGION = "ap-northeast-2"
DOCKER_IMAGE_NAME = "std01-spring-petclinic"
AWS_DEFAULT_REGION = "ap-northeast-2"
ECR_REPOSITORY = "257307634175.dkr.ecr.ap-northeast-2.amazonaws.com"
ECR_DOCKER_IMAGE = "${ECR_REPOSITORY}/${DOCKER_IMAGE_NAME}"
ECR_DOCKER_IMAGE = "${ECR_REPOSITORY}/std01-spring-petclinic"
}
stages {
@ -59,7 +57,7 @@ pipeline {
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("${ECR_REPOSITORY}", "ecr:${AWS_DEFAULT_REGION}") {
docker.image("${ECR_DOCKER_IMAGE}:${BUILD_NUMBER}").push()
docker.image("${ECR_DOCKER_IMAGE}:latest").push()
}
@ -78,7 +76,7 @@ pipeline {
echo 'Upload to S3'
dir("${env.WORKSPACE}"){
sh 'zip -r deploy.zip ./deploy appspec.yaml'
withAWS(region:"${REGION}", credentials: "${AWS_CREDENTIAL_NAME}"){
withAWS(region:"${AWS_DEFAULT_REGION}", credentials: "AWSCredentials"){
s3Upload(file:"deploy.zip", bucket:"std01-codedeploy-bucket")
}
sh 'rm -rf ./deploy.zip'
@ -88,4 +86,3 @@ pipeline {
}
}