Skip to content

Commit

Permalink
♻️ Refactor code. 重构插件支持钉钉机器人
Browse files Browse the repository at this point in the history
  • Loading branch information
721806280 committed Feb 24, 2024
1 parent 1ee6085 commit b70c144
Show file tree
Hide file tree
Showing 144 changed files with 4,491 additions and 3,771 deletions.
28 changes: 1 addition & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
### gradle ###
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar

### STS ###
.settings/
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
rebel.xml

### NetBeans ###
nbproject/private/
build/
nbbuild/
nbdist/
.nb-gradle/

### maven ###
target/
Expand All @@ -35,9 +12,6 @@ target/
*.tar
*.tar.gz

### vscode ###
.vscode

### logs ###
/logs/
*.log
Expand All @@ -57,5 +31,5 @@ Thumbs.db
Servers
.metadata

### jenkins ###
### Jenkins ###
work/
195 changes: 8 additions & 187 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,191 +1,14 @@
## 🌐 插件简介

`feishu-notification-plugin` 是一个用于 `Jenkins`
[飞书机器人](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN)通知插件,可以将 `Jenkins`
构建过程以及结果通知推送到 `飞书` 协作平台。
`lark-notice-plugin` 是一个用于 `Jenkins``构建通知机器人` 通知插件,可以将 `Jenkins`
构建过程以及结果通知推送到 `Lark``飞书``钉钉` 协作平台。
可配置多个的通知时机,包括 `构建启动时``构建中断``构建失败``构建成功时``构建不稳定`等。
支持多种不同类型的消息,包括 `文本消息``图片消息``群名片消息``富文本消息``卡片消息`
同时该插件还提供了`自定义模板``变量`的功能,使您能够根据自己的需求来定制通知消息的内容和格式。

## 📝 使用文档

> 请参考 [官方文档](https://721806280.github.io/feishu-notification-plugin-doc)
#### TEXT 消息

```
pipeline {
agent any
stages {
stage('text'){
steps {
echo '发送文本消息...'
}
post {
success {
feiShuTalk (
robot: 'f72aa1bb-0f0b-47c7-8387-272d266dc25c',
type: 'TEXT',
text: [
"新更新提醒",
'<at user_id="all">所有人</at>'
]
)
}
}
}
}
}
```

#### 群名片消息

```
pipeline {
agent any
stages {
stage('text'){
steps {
echo '发送群名片消息...'
}
post {
success {
feiShuTalk (
robot: 'f72aa1bb-0f0b-47c7-8387-272d266dc25c',
type: 'SHARE_CHAT',
shareChatId: 'oc_f5b1a7eb27ae2c7b6adc2a74faf339ff'
)
}
}
}
}
}
```

#### 图片消息

```
pipeline {
agent any
stages {
stage('text'){
steps {
echo '发送图片消息...'
}
post {
success {
feiShuTalk (
robot: 'f72aa1bb-0f0b-47c7-8387-272d266dc25c',
type: 'IMAGE',
imageKey: 'img_ecffc3b9-8f14-400f-a014-05eca1a4310g'
)
}
}
}
}
}
```

#### 富文本消息

```
pipeline {
agent any
stages {
stage('text'){
steps {
echo '发送富文本消息...'
}
post {
success {
feiShuTalk (
robot: 'f72aa1bb-0f0b-47c7-8387-272d266dc25c',
type: 'POST',
title: '项目更新通知',
post: [
[
[
"tag": "text",
"text": "项目有更新: "
],
[
"tag": "a",
"text": "请查看",
"href": "https://www.example.com/"
],
[
"tag": "at",
"user_id": "ou_xxxxxx",
"user_name": "tom"
]
],
[
[
"tag": "text",
"text": "项目有更新:"
],
[
"tag": "at",
"user_id": "all",
"user_name": "所有人"
]
]
]
)
}
}
}
}
}
```

#### 卡片消息

> 1. 按钮颜色 `type` 的取值范围: primary | danger | default
> 2. 字体颜色 `color` 的取值范围: green:绿色文本 | red:红色文本 | grey:灰色文本 | default:白底黑字样式
```
pipeline {
agent any
stages {
stage('text'){
steps {
echo "发送卡片消息..."
}
post {
success {
feiShuTalk (
robot: "f72aa1bb-0f0b-47c7-8387-272d266dc25c",
type: "INTERACTIVE",
title: "📢 Jenkins 构建通知",
text: [
"📋 **任务名称**:[${JOB_NAME}](${JOB_URL})",
"🔢 **任务编号**:[${BUILD_DISPLAY_NAME}](${BUILD_URL})",
"🌟 **构建状态**: <font color='green'>成功</font>",
"🕐 **构建用时**: ${currentBuild.duration} ms",
"👤 **执 行 者**: Started by user anonymous",
"<at id=all></at>"
],
buttons: [
[
title: "更改记录",
url: "${BUILD_URL}changes"
],
[
title: "控制台",
type: "danger",
url: "${BUILD_URL}console"
]
]
)
}
}
}
}
}
```
> 请参考 [官方文档](https://721806280.github.io/lark-notice-plugin-doc)
## 🧑‍💻 开发服务

Expand Down Expand Up @@ -218,21 +41,19 @@ pipeline {
校验代码规范。
2. 使用 [Google Style Guide](https://github.com/google/styleguide) 统一代码风格。

> `IDEA`下载 [intellij-java-google-style.xml](https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml)
> 通过 `Settings` -> `Editor` `Code Style` 进行导入。
> `IDEA`
>
下载 [intellij-java-google-style.xml](https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml)
> 通过 `Settings` -> `Editor` `Code Style` 进行导入。
## 🔍️ 相关链接

- [Plugin tutorial](https://wiki.jenkins.io/display/JENKINS/Plugin+tutorial#Plugintutorial-SettingUpEnvironment)
- [Jenkins 插件开发之旅:两天内从 idea 到发布(上篇)](https://jenkins-zh.cn/wechat/articles/2019/05/2019-05-06-jenkins-plugin-develop-within-two-days-part01/)
- [Jenkins 插件开发之旅:两天内从 idea 到发布(下篇)](https://jenkins-zh.github.io/wechat/articles/2019/05/2019-05-08-jenkins-plugin-develop-within-two-days-part02/)

## 🍻 开源推荐

- `钉钉插件`[https://github.com/jenkinsci/dingtalk-plugin](https://github.com/jenkinsci/dingtalk-plugin)

## 💚 鸣谢

感谢 JetBrains 提供的免费开源 License

[![JetBrains](docs/img/jetbrains.png)](https://www.jetbrains.com/?from=feishu-notification-plugin)
[![JetBrains](docs/img/jetbrains.png)](https://www.jetbrains.com/?from=lark-notice-plugin)
Loading

0 comments on commit b70c144

Please sign in to comment.