mirror of
https://github.com/cna-bootcamp/lifesub.git
synced 2025-12-06 16:16:22 +00:00
argocd
This commit is contained in:
parent
22f3d384d3
commit
ff8ba72690
@ -10,17 +10,24 @@ podTemplate(
|
|||||||
label: "${PIPELINE_ID}",
|
label: "${PIPELINE_ID}",
|
||||||
serviceAccount: 'jenkins',
|
serviceAccount: 'jenkins',
|
||||||
containers: [
|
containers: [
|
||||||
containerTemplate(name: 'podman', image: "mgoltzsche/podman", ttyEnabled: true, command: 'cat', privileged: true),
|
containerTemplate(name: 'podman',
|
||||||
|
image: "mgoltzsche/podman",
|
||||||
|
ttyEnabled: true,
|
||||||
|
command: 'cat',
|
||||||
|
privileged: true),
|
||||||
containerTemplate(name: 'gradle',
|
containerTemplate(name: 'gradle',
|
||||||
image: 'gradle:jdk17',
|
image: 'gradle:jdk17',
|
||||||
ttyEnabled: true,
|
ttyEnabled: true,
|
||||||
command: 'cat',
|
command: 'cat',
|
||||||
envVars: [
|
envVars: [
|
||||||
envVar(key: 'DOCKER_HOST', value: 'unix:///run/podman/podman.sock'),
|
envVar(key: 'DOCKER_HOST', value: 'unix:///run/podman/podman.sock'),
|
||||||
envVar(key: 'TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE', value: '/run/podman/podman.sock'),
|
envVar(key: 'TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE', value: '/run/podman/podman.sock'),
|
||||||
envVar(key: 'TESTCONTAINERS_RYUK_DISABLED', value: 'true')
|
envVar(key: 'TESTCONTAINERS_RYUK_DISABLED', value: 'true')
|
||||||
]),
|
]),
|
||||||
containerTemplate(name: 'git', image: 'alpine/git:latest', command: 'cat', ttyEnabled: true)
|
containerTemplate(name: 'git',
|
||||||
|
image: 'mikefarah/yq',
|
||||||
|
command: 'cat',
|
||||||
|
ttyEnabled: true)
|
||||||
],
|
],
|
||||||
volumes: [
|
volumes: [
|
||||||
emptyDirVolume(mountPath: '/home/gradle/.gradle', memory: false),
|
emptyDirVolume(mountPath: '/home/gradle/.gradle', memory: false),
|
||||||
@ -31,7 +38,7 @@ podTemplate(
|
|||||||
def props
|
def props
|
||||||
def imageTag = getImageTag()
|
def imageTag = getImageTag()
|
||||||
def services = ['member', 'mysub', 'recommend']
|
def services = ['member', 'mysub', 'recommend']
|
||||||
def manifestRepo = 'https://github.com/cna-bootcamp/lifesub-manifest.git'
|
def manifestRepo = 'cna-bootcamp/lifesub-manifest'
|
||||||
def manifestBranch = 'main'
|
def manifestBranch = 'main'
|
||||||
|
|
||||||
stage("Get Source") {
|
stage("Get Source") {
|
||||||
@ -46,9 +53,9 @@ podTemplate(
|
|||||||
|
|
||||||
container('gradle') {
|
container('gradle') {
|
||||||
def testContainersConfig = '''docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
|
def testContainersConfig = '''docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
|
||||||
docker.host=unix:///run/podman/podman.sock
|
docker.host=unix:///run/podman/podman.sock
|
||||||
ryuk.container.privileged=true
|
ryuk.container.privileged=true
|
||||||
testcontainers.reuse.enable=true'''
|
testcontainers.reuse.enable=true'''
|
||||||
|
|
||||||
sh """
|
sh """
|
||||||
# TestContainers 설정
|
# TestContainers 설정
|
||||||
@ -78,10 +85,10 @@ podTemplate(
|
|||||||
def jarFile = service == 'mysub' ? 'mysub.jar' : "${service}.jar"
|
def jarFile = service == 'mysub' ? 'mysub.jar' : "${service}.jar"
|
||||||
|
|
||||||
sh """
|
sh """
|
||||||
podman build \
|
podman build \\
|
||||||
--build-arg BUILD_LIB_DIR="${buildDir}/build/libs" \
|
--build-arg BUILD_LIB_DIR="${buildDir}/build/libs" \\
|
||||||
--build-arg ARTIFACTORY_FILE="${jarFile}" \
|
--build-arg ARTIFACTORY_FILE="${jarFile}" \\
|
||||||
-f deployment/Dockerfile \
|
-f deployment/Dockerfile \\
|
||||||
-t ${props.registry}/${props.image_org}/${service}:${imageTag} .
|
-t ${props.registry}/${props.image_org}/${service}:${imageTag} .
|
||||||
|
|
||||||
podman push ${props.registry}/${props.image_org}/${service}:${imageTag}
|
podman push ${props.registry}/${props.image_org}/${service}:${imageTag}
|
||||||
@ -98,24 +105,33 @@ podTemplate(
|
|||||||
usernameVariable: 'GIT_USERNAME',
|
usernameVariable: 'GIT_USERNAME',
|
||||||
passwordVariable: 'GIT_PASSWORD'
|
passwordVariable: 'GIT_PASSWORD'
|
||||||
)]) {
|
)]) {
|
||||||
sh """
|
// Git 설정
|
||||||
|
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"
|
||||||
|
'''
|
||||||
|
|
||||||
# Clone manifest repository
|
// Manifest 저장소 클론
|
||||||
git clone https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/cna-bootcamp/lifesub-manifest.git
|
sh '''
|
||||||
cd lifesub-manifest
|
rm -rf lifesub-manifest
|
||||||
|
git clone https://oauth2:${GIT_PASSWORD}@github.com/${manifestRepo}.git
|
||||||
|
'''
|
||||||
|
|
||||||
# Update image tags in deployment files
|
dir('lifesub-manifest') {
|
||||||
for service in ${services.join(' ')}; do
|
services.each { service ->
|
||||||
sed -i 's|image: ${props.registry}/${props.image_org}/'\$service':.*|image: ${props.registry}/${props.image_org}/'\$service':${imageTag}|' lifesub/deployments/\$service-deployment.yaml
|
def imagePath = "${props.registry}/${props.image_org}/${service}:${imageTag}"
|
||||||
done
|
sh """
|
||||||
|
# Update image tag
|
||||||
|
yq e '.spec.template.spec.containers[0].image = "${imagePath}"' -i lifesub/deployments/${service}-deployment.yaml
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
# Commit and push changes
|
sh '''
|
||||||
git add .
|
git add .
|
||||||
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}
|
||||||
"""
|
'''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user