forked from metersphere/jenkins-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
45 lines (45 loc) · 1.94 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
pipeline {
agent {
node {
label 'master'
}
}
options { quietPeriod(2400) }
stages {
stage('Build/Test') {
steps {
configFileProvider([configFile(fileId: 'metersphere-maven', targetLocation: 'settings.xml')]) {
sh "mvn clean package --settings ./settings.xml"
}
}
}
stage('Archive') {
steps {
archiveArtifacts artifacts: 'target/*.hpi', followSymlinks: false
}
}
stage('Release') {
when { tag "v*" }
steps {
withCredentials([string(credentialsId: 'gitrelease', variable: 'TOKEN')]) {
withEnv(["TOKEN=$TOKEN"]) {
sh script: '''
release=$(curl -XPOST -H "Authorization:token $TOKEN" --data "{\\"tag_name\\": \\"${TAG_NAME}\\", \\"name\\": \\"${TAG_NAME}\\", \\"body\\": \\"\\", \\"draft\\": false, \\"prerelease\\": true}" https://api.github.com/repos/metersphere/jenkins-plugin/releases)
id=$(echo "$release" | sed -n -e \'s/"id":\\ \\([0-9]\\+\\),/\\1/p\' | head -n 1 | sed \'s/[[:blank:]]//g\')
cd target
curl -XPOST -H "Authorization:token $TOKEN" -H "Content-Type:application/octet-stream" --data-binary @metersphere-jenkins-plugin.hpi https://uploads.github.com/repos/metersphere/jenkins-plugin/releases/${id}/assets?name=metersphere-jenkins-plugin-${TAG_NAME}.hpi
'''
}
}
}
}
}
post('Notification') {
always {
sh "echo \$WEBHOOK\n"
withCredentials([string(credentialsId: 'wechat-bot-webhook', variable: 'WEBHOOK')]) {
qyWechatNotification failSend: true, mentionedId: '', mentionedMobile: '', webhookUrl: "$WEBHOOK"
}
}
}
}