Skip to content

Commit

Permalink
v2.1.0 (#31)
Browse files Browse the repository at this point in the history
Features:

- 添加 pipeline 调用
- 支持多种消息类型
- 优化默认的展示效果
- 扩展用户属性,添加 `手机号码` 字段
- 支持自动 @ `执行人`
- 添加详细文档

Fixes:

- 修复 `执行人` 显示 SYSTEM 问题

Closed #30, Closed #28, Closed #25, Closed #24, Closed #22
  • Loading branch information
liuweiGL committed Mar 30, 2020
1 parent e58f958 commit 8df64da
Show file tree
Hide file tree
Showing 68 changed files with 10,065 additions and 215 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ work
.idea
*.iml
rebel.xml

# vuepress
docs-dist/
node_modules/
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf",
"jsxSingleQuote": true
}
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: node_js
node_js:
- lts/*
install:
- yarn install # npm ci
script:
- yarn docs:build # npm run docs:build
cache: yarn
deploy:
provider: pages:git
edge: true # opt in to dpl v2
token: $GITHUB_TOKEN # 在 GitHub 中生成,用于允许 Travis 向你的仓库推送代码。在 Travis 的项目设置页面进行配置,添加为环境变量
target_branch: gh-pages
keep_history: true
commit_message: Deploy %{project_name} to %{url}:%{target_branch}
local_dir: docs-dist # Directory to push to GitHub Pages
project_name: DingTalk # Used in the commit message only (defaults to fqdn or the current repo slug)
deployment_file: true # Enable creation of a deployment-info file
skip_cleanup: true # Make sure you have skip_cleanup set to true, otherwise Travis CI will delete all the files created during the build, which will probably delete what you are trying to upload.
on:
branch: master
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@

1. 使用 [Alibaba Java Coding Guidelines](https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines/) 校验代码规范。
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` 进行导入。
## 文档服务

1. 安装 node.js 环境
2. 安装 yarn 包管理器
3. 在项目根目录执行 `yarn` 安装依赖
4. 执行 `yarn docs:dev` 启动文档开发环境
5. 代码合并到 `master` 之后会自动发布
File renamed without changes.
Binary file removed doc/images/contribuitingConfig.png
Binary file not shown.
Binary file removed doc/images/globalConfig.png
Binary file not shown.
Binary file removed doc/images/globalConfigTest.png
Binary file not shown.
Binary file removed doc/images/projectBuildTest.png
Binary file not shown.
Binary file removed doc/images/projectConfig.png
Binary file not shown.
60 changes: 60 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const path = require('path')

module.exports = {
base: '/dingding-notifications-plugin/',
port: 8888,
dest: 'docs-dist',
title: '钉钉机器人插件',
description: '在 Jenkins 中使用钉钉机器人发送消息',
configureWebpack: {
resolve: {
alias: {
'@': path.resolve(__dirname, '../')
}
}
},
markdown: {
anchor: { permalink: true }
},
themeConfig: {
docsDir: 'docs',
repo: 'jenkinsci/dingding-notifications-plugin',
sidebarDepth: 1,
editLinks: true,
editLinkText: '在 GitHub 上编辑此页',
lastUpdated: '上次更新',
nav: [
{
text: '发布记录',
link:
'https://github.com/jenkinsci/dingding-notifications-plugin/releases'
}
],
sidebar: [
{
title: '指南',
path: '/guide/getting-started',
collapsable: false,
children: ['/guide/getting-started', '/guide/simple','/guide/pipeline']
},
{
title: '进阶',
path: '/advance/getting-started',
collapsable: false,
children: ['/advance/user-property', '/advance/markdown']
},
{
title: '示例',
path: '/examples/text',
collapsable: false,
children: [
'/examples/text',
'/examples/link',
'/examples/markdown',
'/examples/actionCardSingle',
'/examples/actionCardMultiple'
]
}
]
}
}
6 changes: 6 additions & 0 deletions docs/.vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default ({
Vue,
options, // 附加到根实例的一些选项
router, // 当前应用的路由实例
siteData // 站点元数据
}) => {}
124 changes: 124 additions & 0 deletions docs/advance/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Markdown

## 钉钉支持的语法

目前只支持 md 语法的子集,具体支持的元素如下:

```markdown

标题
# 一级标题
## 二级标题
### 三级标题
#### 四级标题
##### 五级标题
###### 六级标题

引用
> A man who stands for nothing will fall for anything.

文字加粗、斜体
**bold**
*italic*

链接
[this is a link](http://name.com)

图片
![](http://name.com/pic.jpg)

无序列表
- item1
- item2

有序列表
1. item1
2. item2

```

## 定制文字

经测试钉钉支持在 markdown 中使用 [font](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/font) 标签。

示例:

1. <font color=red>红色文字</font>

```markdown

<font color=red>红色文字</font>

```

2. *<font color=red>红色-斜体文字</font>*

```markdown

*<font color=red>红色-斜体文字</font>*

```

3. **<font color=red>红色-加粗文字</font>**

```markdown

**<font color=red>红色-加粗</font>**

```

4. ***<font color=red>红色-斜体-加粗文字</font>***

```markdown

***<font color=red>红色-斜体-加粗</font>***

```

5. <font color=red size=0 >红色-小号文字</font>

```markdown

<font color=red size=0 >红色-小号文字</font>

```

6. <font color=red size=3 >红色-正常大小文字</font>

```markdown

<font color=red size=3 >红色-正常大小文字</font>

```


7. <font color=red size=7 >红色-大号文字</font>

```markdown

<font color=red size=7 >红色-大号文字</font>

```

8. <font color=red face=KaiTi>红色-楷体文字</font>

```markdown

<font color=red face=KaiTi>红色-楷体文字</font>

```

::: warning

`face` 属性暂未经过测试,在钉钉中表现未知。

:::

::: danger

同样的 markdown 内容在 `MARKDOWN``ACTION_CARD` 消息中表现可能不一致,系正常现象,在意的可以去钉钉官方群反馈。
:::

![dingTalkLogo](@/assets/dingTalk-logo.png)

“钉钉机器人交流群(阿里同学加内部群,单聊找我)”群的钉钉群号: 11733391
27 changes: 27 additions & 0 deletions docs/advance/user-property.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 用户属性扩展

为了实现 `执行人` 字段带 `@` 效果,需要为 Jenkins 用户补充相关信息。

1. 打开 **Manage Users**

::: details 查看详细

![manage-users](@/assets/manage-users.jpg)

:::

2. 设置用户

::: details 查看详细

![user-setting](@/assets/user-setting.jpg)

:::

3. 添加属性

::: details 查看详细

![user-detail](@/assets/user-detail.jpg)

:::
Binary file added docs/assets/actionCardMultiple-atAll-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/actionCardMultiple-btns-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/actionCardSingle-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/dingTalk-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/freestyle-project-config.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/global-config.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/link-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/manage-users.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/markdown-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/robotId.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/simple-at-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/simple-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/text-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/user-detail.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/user-setting.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions docs/examples/actionCardMultiple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# ACTION_CARD 整体跳转

## 基础用法

```groovy
pipeline {
agent any
stages {
stage('link'){
steps {
echo '测试 ACTION_CARD 整体跳转消息...'
}
post {
success {
dingTalk (
robot: '58f10219-2cd3-4de7-a1af-f85f4010c10a',
type: 'ACTION_CARD',
title: '你有新的消息,请注意查收',
text: [
'![screenshot](@lADOpwk3K80C0M0FoA)',
'### 乔布斯 20 年前想打造的苹果咖啡厅 ',
'Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划'
],
)
}
}
}
}
}
```

:::details 查看结果

![actionCardMultiple-default-example](@/assets/actionCardMultiple-default-example.jpg)

:::

## 自定义按钮组

```groovy
btns: [
[
title: '内容不错',
actionUrl: 'https://www.dingtalk.com/'
],
[
title: '不感兴趣',
actionUrl: 'https://www.dingtalk.com/'
]
]
```

:::details 查看结果

![actionCardMultiple-btns-example](@/assets/actionCardMultiple-btns-example.jpg)

:::

## 改变按钮排列方式

```groovy
btnLayout: 'V'
```

:::details 查看结果

![actionCardMultiple-btnLayout-example](@/assets/actionCardMultiple-btnLayout-example.jpg)

:::

## At 全部

```groovy
atAll: true
```

:::details 查看结果

![actionCardMultiple-atAll-example](@/assets/actionCardMultiple-atAll-example.jpg)

:::
Loading

0 comments on commit 8df64da

Please sign in to comment.