MeterSphere/Jenkinsfile

70 lines
2.5 KiB
Plaintext
Raw Permalink Normal View History

properties([ [ $class: 'ThrottleJobProperty',
categories: ['metersphere'],
limitOneJobWithMatchingParams: false,
maxConcurrentPerNode: 1,
maxConcurrentTotal: 1,
paramsToUseForLimit: '',
throttleEnabled: true,
throttleOption: 'category' ] ])
2020-12-18 11:57:58 +08:00
pipeline {
agent {
node {
2022-05-05 22:07:46 +08:00
label 'metersphere'
2020-12-18 11:57:58 +08:00
}
}
2022-08-20 19:41:03 +08:00
triggers {
2022-09-22 18:20:04 +08:00
pollSCM('0 22 * * *')
2022-08-20 19:41:03 +08:00
}
2021-01-05 17:25:24 +08:00
environment {
IMAGE_NAME = 'metersphere'
IMAGE_PREFIX = 'registry.cn-qingdao.aliyuncs.com/metersphere'
2020-12-18 11:57:58 +08:00
}
stages {
stage('Preparation') {
steps {
script {
REVISION = ""
if (env.BRANCH_NAME.startsWith("v") ) {
REVISION = env.BRANCH_NAME.substring(1)
} else {
REVISION = env.BRANCH_NAME
}
env.REVISION = "${REVISION}"
echo "REVISION=${REVISION}"
}
}
}
2020-12-18 11:57:58 +08:00
stage('Build/Test') {
steps {
configFileProvider([configFile(fileId: 'metersphere-maven', targetLocation: 'settings.xml')]) {
2022-03-17 19:40:17 +08:00
sh '''
export JAVA_HOME=/opt/jdk-11
export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
2022-04-20 18:35:25 +08:00
export PATH=$JAVA_HOME/bin:/opt/mvnd/bin:$PATH
2022-03-17 19:40:17 +08:00
java -version
mvnd clean package -Drevision=${REVISION} -DskipAntRunForJenkins --settings ./settings.xml
2022-03-17 19:40:17 +08:00
mkdir -p backend/target/dependency && (cd backend/target/dependency; jar -xf ../*.jar)
'''
2020-12-18 11:57:58 +08:00
}
}
}
stage('Docker build & push') {
steps {
sh '''
2022-06-29 20:43:26 +08:00
su - metersphere -c "cd ${WORKSPACE} && docker buildx create --use && docker buildx build --build-arg MS_VERSION=\${TAG_NAME:-\$BRANCH_NAME}-\${GIT_COMMIT:0:8} -t ${IMAGE_PREFIX}/${IMAGE_NAME}:\${TAG_NAME:-\$BRANCH_NAME} --platform linux/amd64,linux/arm64 . --push"
'''
2020-12-18 11:57:58 +08:00
}
}
2020-12-21 14:06:32 +08:00
}
post('Notification') {
always {
sh "echo \$WEBHOOK\n"
withCredentials([string(credentialsId: 'wechat-bot-webhook', variable: 'WEBHOOK')]) {
2022-03-27 16:49:45 +08:00
qyWechatNotification failNotify: true, mentionedId: '', mentionedMobile: '', webhookUrl: "$WEBHOOK"
}
2022-03-15 18:09:39 +08:00
sh "./mvnw clean"
}
2020-12-18 11:57:58 +08:00
}
}