release
This commit is contained in:
parent
970ef22d9c
commit
a29eddd18d
@ -10,9 +10,19 @@ podTemplate(
|
|||||||
label: "${PIPELINE_ID}",
|
label: "${PIPELINE_ID}",
|
||||||
serviceAccount: 'jenkins',
|
serviceAccount: 'jenkins',
|
||||||
containers: [
|
containers: [
|
||||||
containerTemplate(name: 'node', image: 'node:20-slim', ttyEnabled: true, command: 'cat'),
|
containerTemplate(name: 'node',
|
||||||
containerTemplate(name: 'podman', image: "mgoltzsche/podman", ttyEnabled: true, command: 'cat', privileged: true),
|
image: 'node:20-slim',
|
||||||
containerTemplate(name: 'git', image: 'alpine/git:latest', command: 'cat', ttyEnabled: true)
|
ttyEnabled: true,
|
||||||
|
command: 'cat'),
|
||||||
|
containerTemplate(name: 'podman',
|
||||||
|
image: "mgoltzsche/podman",
|
||||||
|
ttyEnabled: true,
|
||||||
|
command: 'cat',
|
||||||
|
privileged: true),
|
||||||
|
containerTemplate(name: 'git',
|
||||||
|
image: 'alpine:3.19',
|
||||||
|
command: 'cat',
|
||||||
|
ttyEnabled: true)
|
||||||
],
|
],
|
||||||
volumes: [
|
volumes: [
|
||||||
emptyDirVolume(mountPath: '/root/.azure', memory: false)
|
emptyDirVolume(mountPath: '/root/.azure', memory: false)
|
||||||
@ -21,7 +31,7 @@ podTemplate(
|
|||||||
node(PIPELINE_ID) {
|
node(PIPELINE_ID) {
|
||||||
def props
|
def props
|
||||||
def imageTag = getImageTag()
|
def imageTag = getImageTag()
|
||||||
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") {
|
||||||
@ -41,14 +51,14 @@ podTemplate(
|
|||||||
sh """
|
sh """
|
||||||
podman login ${props.registry} --username \$USERNAME --password \$PASSWORD
|
podman login ${props.registry} --username \$USERNAME --password \$PASSWORD
|
||||||
|
|
||||||
podman build \
|
podman build \\
|
||||||
--build-arg PROJECT_FOLDER="." \
|
--build-arg PROJECT_FOLDER="." \\
|
||||||
--build-arg REACT_APP_MEMBER_URL="${props.react_app_member_url}" \
|
--build-arg REACT_APP_MEMBER_URL="${props.react_app_member_url}" \\
|
||||||
--build-arg REACT_APP_MYSUB_URL="${props.react_app_mysub_url}" \
|
--build-arg REACT_APP_MYSUB_URL="${props.react_app_mysub_url}" \\
|
||||||
--build-arg REACT_APP_RECOMMEND_URL="${props.react_app_recommend_url}" \
|
--build-arg REACT_APP_RECOMMEND_URL="${props.react_app_recommend_url}" \\
|
||||||
--build-arg BUILD_FOLDER="deployment" \
|
--build-arg BUILD_FOLDER="deployment" \\
|
||||||
--build-arg EXPORT_PORT="${props.export_port}" \
|
--build-arg EXPORT_PORT="${props.export_port}" \\
|
||||||
-f deployment/Dockerfile-lifesub-web \
|
-f deployment/Dockerfile-lifesub-web \\
|
||||||
-t ${imagePath} .
|
-t ${imagePath} .
|
||||||
|
|
||||||
podman push ${imagePath}
|
podman push ${imagePath}
|
||||||
@ -59,28 +69,38 @@ podTemplate(
|
|||||||
|
|
||||||
stage('Update Manifest') {
|
stage('Update Manifest') {
|
||||||
container('git') {
|
container('git') {
|
||||||
|
// git과 yq 설치
|
||||||
|
sh '''
|
||||||
|
apk add --no-cache git curl
|
||||||
|
curl -L https://github.com/mikefarah/yq/releases/download/v4.40.5/yq_linux_amd64 -o /usr/local/bin/yq
|
||||||
|
chmod +x /usr/local/bin/yq
|
||||||
|
'''
|
||||||
|
|
||||||
withCredentials([usernamePassword(
|
withCredentials([usernamePassword(
|
||||||
credentialsId: 'github-credentials',
|
credentialsId: 'github-credentials',
|
||||||
usernameVariable: 'GIT_USERNAME',
|
usernameVariable: 'GIT_USERNAME',
|
||||||
passwordVariable: 'GIT_PASSWORD'
|
passwordVariable: 'GIT_PASSWORD'
|
||||||
)]) {
|
)]) {
|
||||||
// Configure 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"
|
||||||
|
'''
|
||||||
# Clone manifest repository
|
|
||||||
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://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${manifestRepo}.git
|
||||||
# Update image tag in deployment yaml
|
|
||||||
sed -i 's|image: ${props.registry}/${props.image_org}/lifesub-web:.*|image: ${props.registry}/${props.image_org}/lifesub-web:${imageTag}|' lifesub-web/deployments/lifesub-web-deployment.yaml
|
|
||||||
|
|
||||||
# Commit and push changes
|
|
||||||
git add .
|
|
||||||
git commit -m "Update lifesub-web image to ${imageTag}"
|
|
||||||
git push origin ${manifestBranch}
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
dir('lifesub-manifest') {
|
||||||
|
def imagePath = "${props.registry}/${props.image_org}/lifesub-web:${imageTag}"
|
||||||
|
sh """
|
||||||
|
yq -i '.spec.template.spec.containers[0].image = "${imagePath}"' lifesub-web/deployments/lifesub-web-deployment.yaml
|
||||||
|
|
||||||
|
git add .
|
||||||
|
git diff-index --quiet HEAD || git commit -m "Update lifesub-web image to ${imageTag}"
|
||||||
|
git push origin ${manifestBranch}
|
||||||
|
"""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user