Integrate Jenkins with Enterprise WeChat for Real-Time Build Alerts
This guide shows how to integrate Jenkins with Enterprise WeChat by installing the wxwork-notification plugin, configuring a smart robot webhook, and adding pipeline post steps that send markdown success or failure alerts to a WeChat group, complete with code examples and screenshots.
Background
After Jenkins deployment succeeds, how can you quickly notify the relevant personnel? Previously I explained email notifications, but instant‑messaging tools like Enterprise WeChat or DingTalk provide faster alerts. This article explains how to integrate Jenkins with Enterprise WeChat notifications.
Enterprise WeChat Smart Robot
Enterprise WeChat smart robot is an AI dialogue system within the Enterprise WeChat ecosystem, offering auto‑reply, multi‑turn conversation, data accumulation, and supporting text and voice multimodal interaction. It can be customized with a knowledge base and uses NLP and knowledge graphs to understand user language. Its main functions include:
Answer internal employee questions : e.g., company policies, reimbursement processes.
Assist external customer inquiries : product information, after‑sales issues.
Improve efficiency : 24/7 response, reducing manual support load.
Optimize experience : standardized service, avoiding emotional fluctuations.
Reduce cost : low long‑term cost after a one‑time investment.
Why Add a Smart Robot to Jenkins
Jenkins is a popular automation tool for CI/CD. Adding a smart robot provides:
Automated notifications : push build status, test results to the team in real time.
Fault diagnosis : on build failure, the robot can quickly analyze logs and suggest possible causes.
Note: Jenkins does not natively support smart robots; integration requires plugins or APIs.
Practical: Push Jenkins Deployment Notifications
Test Enterprise WeChat Robot
Add a group robot in a chat group.
Test Robot
Configure the robot's webhook address; this URL will be copied into Jenkins configuration.
Use Postman to test sending a message to the webhook.
After a successful request, the robot message appears in Enterprise WeChat.
Install Jenkins Plugin
Jenkins does not include Enterprise WeChat tools by default; install the Enterprise WeChat plugin from the Jenkins plugin marketplace.
Enter robot ID, name, and webhook address. The robot ID must be unique within this Jenkins instance.
Test Plugin Push to Group Chat
In Jenkins you can test whether the plugin is configured correctly; clicking the test button sends a notification to the group.
Add Phone Number
The phone number is used to locate members in Enterprise WeChat and @ them.
Deployment Script
Add the following code to the Jenkins pipeline script to notify relevant personnel on success or failure. The message format uses markdown for better visual appearance.
post {
success {
script {
echo "成功时通知触发构建者"
wxwork(
robot:'robot1',
type:'markdown',
text:[
"部署<font color=\"green\">成功</font>通知",
">项目: <font color=\"comment\">后端</font>",
">任务名: <font color=\"comment\">${env.JOB_NAME}</font>",
">模块: <font color=\"comment\">${params.SERVICE_NAME}</font>",
">分支: <font color=\"comment\">${params.GIT_BRANCH}</font>",
">部署ID: <font color=\"comment\"># ${env.BUILD_NUMBER}</font>",
">构建日志: <font color=\"comment\">${currentBuild.absoluteUrl}</font>"
]
)
}
}
failure {
script {
echo "失败时通知提交者"
wxwork(
robot:'robot1',
type:'markdown',
text:[
"部署<font color=\"red\">失败</font>通知",
">项目: <font color=\"comment\">后端</font>",
">任务名: <font color=\"comment\">${env.JOB_NAME}</font>",
">模块: <font color=\"comment\">${params.SERVICE_NAME}</font>",
">分支: <font color=\"comment\">${params.GIT_BRANCH}</font>",
">部署ID: <font color=\"comment\"># ${env.BUILD_NUMBER}</font>",
">构建日志: <font color=\"comment\">${currentBuild.absoluteUrl}</font>"
]
)
}
}
}Full template code download:
https://gitee.com/jayh2018/passjava-script/blob/master/jenkins/wework-notice.groovyDeployment Success Notification
Deployment Failure Notification
Summary
Install the Enterprise WeChat plugin in Jenkins and fill in the robot webhook to push build results to a WeChat group in real time.
In the pipeline post stage, call wxwork() to send markdown messages with links and @ mentions for success or failure scenarios.
Reference: https://plugins.jenkins.io/wxwork-notification
Wukong Talks Architecture
Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
