基于Jira的运维发布平台的设计与实现
复制#!groovy
@Library(lotbrick) _
def gitlab = new org.devops.gitlab()
def tool = new org.devops.tools()
def dingmes = new org.devops.sendDingTalk()
pipeline {
agent { node { label "master"}}
environment {
DINGTALKHOOK = "https://oapi.dingtalk.com/robot/send?access_token=xxxx"
}
stages{
stage("FileterData"){
steps{
script{
response = readJSON text: """${webHookData}"""
// println(response)
env.eventType = response["webhookEvent"]
if (eventType == "jira:issue_updated"){
// 获取状态值
env.jiraStatus = response[issue][fields][status][name]
env.gitlabInfos = response[issue][fields][customfield_10219]
infos = "${gitlabInfos}".split("\r\n")
for (info in infos){
prName = "$info".split("/")[0]
// brName = "$info".split("/")[1]
brName = info - "${prName}/"
println(prName)
println(brName)
if (jiraStatus == "已发布(UAT)"){
println(进行合并PRE分支操作)
}else if (jiraStatus == "已发布(PROD)"){
println(进行合并PROD分支操作)
}else if (jiraStatus == "已完成"){
println(进行分支打Tag并删除原分支)
}else{
println("查无此项")
}
}
}
}
}
}
}
// 构建后的操作
post {
failure {
script{
println("failure:只有构建失败才会执行")
dingmes.SendDingTalk("分支合并失败 ❌")
}
}
aborted {
script{
println("aborted:只有取消构建才会执行")
dingmes.SendDingTalk("分支合并取消 ❌","暂停或中断")
}
}
}
}
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.
THE END