Skip to content

Commit

Permalink
完善说明文档
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoimi committed Aug 19, 2024
1 parent 90a0c4b commit 7d77382
Showing 1 changed file with 103 additions and 1 deletion.
104 changes: 103 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- 配置企业微信机器人:需要在 jenkins 系统配置中配置企业微信机器人,支持配置多个机器人
- 配置用户的手机号码:需要在 jenkins 用户信息页面,配置企业微信成员手机号码,用于在企业微信中 @ 成员

- Jenkinsfile
- Jenkinsfile (脚本写法)

```groovy
#!groovy
Expand Down Expand Up @@ -68,6 +68,108 @@ node {
}
```

- Jenkinsfile (声明式写法)

```groovy
pipeline {
agent any
stages {
stage('Hello') {
steps {
echo 'Hello World'
// 发送消息
wxwork(
robot: 'test',
type: 'text',
text: [
"stage: Hello",
"displayName: ${currentBuild.displayName}",
"absoluteUrl: ${currentBuild.absoluteUrl}"
]
)
}
}
stage('build') {
steps {
script {
println "build number: ${currentBuild.number}";
println "current result: ${currentBuild.currentResult}";
println "build URL: ${currentBuild.absoluteUrl}";
// 发送消息
wxwork(
robot: 'test',
type: 'text',
text: [
"stage: build",
"displayName: ${currentBuild.displayName}",
"absoluteUrl: ${currentBuild.absoluteUrl}"
]
)
}
}
}
stage('some-stage') {
steps {
script {
println "build number: ${currentBuild.number} - some stage";
// err
sh "fsdfsdf"
// 发送消息
wxwork(
robot: 'test',
type: 'text',
text: [
"stage: some-stage",
"displayName: ${currentBuild.displayName}",
"absoluteUrl: ${currentBuild.absoluteUrl}"
]
)
}
}
}
}
post {
always {
// 无论什么情况都发送消息
wxwork(
robot: 'test',
type: 'text',
text: [
"post-always",
"displayName: ${currentBuild.displayName}",
"absoluteUrl: ${currentBuild.absoluteUrl}"
]
)
}
failure {
script {
// 状态异常
wxwork(
robot: 'test',
type: 'text',
text: [
"post-failure",
"displayName: ${currentBuild.displayName}",
"absoluteUrl: ${currentBuild.absoluteUrl}"
]
)
}
}
}
}
```

- 企业微信机器人开发文档: [企业微信官方文档](https://developer.work.weixin.qq.com/document/path/91770?version=4.0.8.6027&platform=win)

### LICENSE
Expand Down

0 comments on commit 7d77382

Please sign in to comment.