-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b332466
commit 9f2f503
Showing
4 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
pipeline { | ||
agent any | ||
|
||
tools { | ||
jdk 'JDK21' | ||
} | ||
|
||
environment { | ||
DOCKERHUB_CREDENTIALS = credentials('dockerhub-credentials-id') | ||
DOCKER_IMAGE = credentials('docker-image-dev') | ||
K8S_URL = credentials('k8s-url') | ||
K8S_NAMESPACE = credentials('k8s-namespace') | ||
K8S_DEPLOY_NAME = credentials('k8s-deploy-name-dev') | ||
JAVA_HOME = "${tool 'JDK21'}" | ||
PATH = "${env.JAVA_HOME}/bin:${env.PATH}" | ||
} | ||
|
||
stages { | ||
stage('Checkout') { | ||
steps { | ||
checkout scm | ||
} | ||
} | ||
|
||
stage('Build & Test') { | ||
steps { | ||
script { | ||
sh 'mkdir -p $WORKSPACE/src/main/resources/static/docs && touch $WORKSPACE/src/main/resources/static/docs/open-api-3.0.1.json' | ||
sh './gradlew clean build -x test' | ||
sh './gradlew openapi3' | ||
} | ||
} | ||
post { | ||
failure { | ||
error 'Deployment failed!' | ||
} | ||
} | ||
} | ||
|
||
stage('Login'){ | ||
steps{ | ||
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' // docker hub 로그인 | ||
} | ||
} | ||
|
||
stage('Build & Push Docker Image') { | ||
steps { | ||
script { | ||
sh 'docker buildx build --push --platform linux/amd64 --build-arg PROFILE=dev -t $DOCKER_IMAGE .' | ||
} | ||
} | ||
} | ||
|
||
stage('ssh-test') { | ||
steps{ | ||
script{ | ||
sshagent (credentials: ['ncp-key']) { | ||
sh """ | ||
ssh -o StrictHostKeyChecking=no ${K8S_URL} << EOF | ||
microk8s kubectl rollout restart deploy ${K8S_DEPLOY_NAME} -n=${K8S_NAMESPACE} | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
post { | ||
success { | ||
echo 'Deployment was successful!' | ||
} | ||
failure { | ||
error 'Deployment failed!' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters