map/Jenkinsfile

92 lines
3.4 KiB
Groovy

pipeline {
parameters {
choice choices: ['all', 'ui', 'dn', 'service'], description: 'all - 前端和后端 ; ui - 仅发版前端 ; dn - 采集程序 service - 仅发版后端', name: 'publish_type'
}
agent none
stages {
stage('拉取源码') {
agent any
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'd62224c5-69cf-474a-8845-c2c2bbe1fc00', url: 'https://git.jsspisoft.com/ry-das.git']])
}
}
stage('编译UI') {
agent any
when {
expression { params.publish_type == "ui" || params.publish_type == "all" }
}
steps {
nodejs(cacheLocationStrategy: workspace(), configId: '8e356590-2fee-4f1f-b0e9-5cea43299887', nodeJSInstallationName: 'nodejs2211') {
dir("$WORKSPACE/ui/dasadmin") {
sh "npm install"
sh "npm run build"
}
}
}
}
stage('编译后端') {
agent any
when {
expression { params.publish_type == "service" || params.publish_type == "all" }
}
steps {
withMaven(globalMavenSettingsConfig: 'bab2e7fd-587c-4284-9bd8-6b97dfeb2fab', jdk: 'jdk17', maven: 'maven396') {
dir("$WORKSPACE/das") {
sh 'mvn -DskipTests -am clean package'
}
}
}
}
stage('编译采集程序') {
agent {
docker {
image 'docker.jsspisoft.com/common/openeuler:24.03-builder'
}
}
when {
expression { params.publish_type == "dn" || params.publish_type == "all" }
}
steps {
dir("$WORKSPACE/das-dn") {
sh 'cmake --preset default'
sh 'cmake --build build'
}
}
}
stage('发版前端') {
agent any
when {
expression { params.publish_type == "ui" || params.publish_type == "all" }
}
steps {
dir("$WORKSPACE/ui/dasadmin") {
sh "sudo rsync -av --delete dist/ root@192.168.109.187:/das/app/ui/"
}
}
}
stage('发版后端') {
agent any
when {
expression { params.publish_type == "service" || params.publish_type == "all" }
}
steps {
dir("$WORKSPACE/das") {
sh 'sudo rsync -av target/das-1.0.0-release.jar root@192.168.109.187:/das/app/das/'
sh 'sudo ssh -t root@192.168.109.187 systemctl restart das'
}
}
}
stage('发版采集程序') {
agent any
when {
expression { params.publish_type == "dn" || params.publish_type == "all" }
}
steps {
dir("$WORKSPACE/das-dn") {
sh 'sudo rsync -av build/application root@192.168.109.187:/das/app/das-dn/bin/'
sh 'sudo ssh -t root@192.168.109.187 systemctl restart das-dn'
}
}
}
}
}