pipeline {
agent any
environment {
name="${JOB_NAME}"
times="${currentBuild.duration}"
task="${BUILD_ID}"
logs="${ChangeLog}"
}
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
}
post {
success {
sh '''
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=98093e2b-d30f-4fe4-930d-ffb52a22862' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "#### 构建成功 ✅:'$name'项目! \n
>### 持续时间:'$times'
>### 任务:#'$task'"
}
}'
'''
}
failure {
sh '''
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=98093e2b-d30f-4fe4-930d-ffb52a2b262' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "#### 构建失败 ❌'$name'项目! \n
>### 持续时间:'$times'
>### 任务:#'$task'"
}
}'
'''
echo 'failure'
}
}
}
Jenkins之post推送企业微信消息
最新推荐文章于 2023-12-28 09:31:57 发布