|
|
@@ -0,0 +1,83 @@
|
|
|
+pipeline {
|
|
|
+ agent any
|
|
|
+
|
|
|
+ environment {
|
|
|
+ DEPLOY_SERVER = "greentech@39.105.38.31"
|
|
|
+ DEPLOY_REPO_PATH = "/home/greentech/services/ultrafiltration_model"
|
|
|
+ HARBOR_URL = "172.16.0.165:5000/simulations"
|
|
|
+ IMAGE_NAME = "ultrafiltration_model"
|
|
|
+ }
|
|
|
+
|
|
|
+ stages {
|
|
|
+ stage('获取commit哈希') {
|
|
|
+ steps {
|
|
|
+ git branch: "${APP_GIT_BRANCH}",
|
|
|
+ url: "${APP_GIT_URL}",
|
|
|
+ credentialsId: "git-public"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('拉取代码') {
|
|
|
+ steps {
|
|
|
+ withCredentials([usernamePassword(
|
|
|
+ credentialsId: 'gpu1key',
|
|
|
+ usernameVariable: 'USER',
|
|
|
+ passwordVariable: 'PWD'
|
|
|
+ )]) {
|
|
|
+ sh """
|
|
|
+ sshpass -p '$PWD' ssh -o StrictHostKeyChecking=no $USER@39.105.38.31 "
|
|
|
+ cd ${DEPLOY_REPO_PATH} &&
|
|
|
+ git pull origin ${APP_GIT_BRANCH}
|
|
|
+ "
|
|
|
+ """
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('构建并推送镜像') {
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ def gitCommitShort = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
|
|
+ withCredentials([usernamePassword(
|
|
|
+ credentialsId: 'gpu1key',
|
|
|
+ usernameVariable: 'USER',
|
|
|
+ passwordVariable: 'PWD'
|
|
|
+ )]) {
|
|
|
+ sh """
|
|
|
+ sshpass -p '$PWD' ssh -o StrictHostKeyChecking=no $USER@39.105.38.31 "
|
|
|
+ cd ${DEPLOY_REPO_PATH} &&
|
|
|
+ export HARBOR_URL=${HARBOR_URL} &&
|
|
|
+ export IMAGE_NAME=${IMAGE_NAME} &&
|
|
|
+ export GIT_COMMIT_SHORT=${gitCommitShort} &&
|
|
|
+ chmod +x build.sh &&
|
|
|
+ ./build.sh
|
|
|
+ "
|
|
|
+ """
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stage('部署到生产环境') {
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ def gitCommitShort = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
|
|
+
|
|
|
+ withCredentials([usernamePassword(
|
|
|
+ credentialsId: 'gpu1key',
|
|
|
+ usernameVariable: 'USER',
|
|
|
+ passwordVariable: 'PWD'
|
|
|
+ )]) {
|
|
|
+ sh """
|
|
|
+ sshpass -p '$PWD' ssh -o StrictHostKeyChecking=no $USER@39.105.38.31 "
|
|
|
+ export GIT_COMMIT_SHORT=${gitCommitShort}
|
|
|
+ cd ${DEPLOY_REPO_PATH} &&
|
|
|
+ docker compose pull && docker compose up -dV
|
|
|
+ "
|
|
|
+ """
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|