forked from thup/node-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
69 lines (68 loc) · 2.46 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
properties([ [ $class: 'ThrottleJobProperty',
categories: ['metersphere'],
limitOneJobWithMatchingParams: false,
maxConcurrentPerNode: 1,
maxConcurrentTotal: 1,
paramsToUseForLimit: '',
throttleEnabled: true,
throttleOption: 'category' ] ])
pipeline {
agent {
node {
label 'metersphere'
}
}
triggers {
pollSCM('0 * * * *')
}
environment {
JAVA_HOME = '/opt/jdk-17'
IMAGE_NAME = 'node-controller'
IMAGE_PREFIX = 'registry.cn-qingdao.aliyuncs.com/metersphere'
}
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}"
}
}
}
stage('Build/Test') {
steps {
configFileProvider([configFile(fileId: 'metersphere-maven', targetLocation: 'settings.xml')]) {
sh '''
export JAVA_HOME=/opt/jdk-17
export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
java -version
./mvnw clean package -Drevision=${REVISION} --settings ./settings.xml
mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
'''
}
}
}
stage('Docker build & push') {
steps {
sh '''#!/bin/bash -xe
docker --config /home/metersphere/.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
'''
}
}
}
post('Notification') {
always {
sh "echo \$WEBHOOK\n"
withCredentials([string(credentialsId: 'wechat-bot-webhook', variable: 'WEBHOOK')]) {
qyWechatNotification failNotify: true, mentionedId: '', mentionedMobile: '', webhookUrl: "$WEBHOOK"
}
}
}
}