This commit is contained in:
hiondal 2025-02-18 05:07:31 +09:00
parent ff8ba72690
commit 68330ded2e

View File

@ -25,7 +25,7 @@ podTemplate(
envVar(key: 'TESTCONTAINERS_RYUK_DISABLED', value: 'true') envVar(key: 'TESTCONTAINERS_RYUK_DISABLED', value: 'true')
]), ]),
containerTemplate(name: 'git', containerTemplate(name: 'git',
image: 'mikefarah/yq', image: 'ghcr.io/chriswhong/git-yq:latest',
command: 'cat', command: 'cat',
ttyEnabled: true) ttyEnabled: true)
], ],
@ -105,32 +105,31 @@ testcontainers.reuse.enable=true'''
usernameVariable: 'GIT_USERNAME', usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD' passwordVariable: 'GIT_PASSWORD'
)]) { )]) {
// Git 설정
sh ''' sh '''
git config --global user.email "jenkins@example.com" git config --global user.email "jenkins@example.com"
git config --global user.name "Jenkins" git config --global user.name "Jenkins"
''' '''
// Manifest 저장소 클론 // manifest 저장소를 https 프로토콜로 클론
sh ''' sh """
rm -rf lifesub-manifest rm -rf lifesub-manifest
git clone https://oauth2:${GIT_PASSWORD}@github.com/${manifestRepo}.git git clone https://oauth2:${GIT_PASSWORD}@github.com/${manifestRepo}.git
''' """
dir('lifesub-manifest') { dir('lifesub-manifest') {
services.each { service -> services.each { service ->
def imagePath = "${props.registry}/${props.image_org}/${service}:${imageTag}" def imagePath = "${props.registry}/${props.image_org}/${service}:${imageTag}"
sh """ sh """
# Update image tag # deployment yaml 파일의 이미지 태그 업데이트
yq e '.spec.template.spec.containers[0].image = "${imagePath}"' -i lifesub/deployments/${service}-deployment.yaml yq -i '.spec.template.spec.containers[0].image = "${imagePath}"' lifesub/deployments/${service}-deployment.yaml
""" """
} }
sh ''' sh """
git add . git add .
git diff-index --quiet HEAD || git commit -m "Update backend services images to ${imageTag}" git diff-index --quiet HEAD || git commit -m "Update backend services images to ${imageTag}"
git push origin ${manifestBranch} git push origin ${manifestBranch}
''' """
} }
} }
} }