2

Hubot集成企业钉钉

 1 year ago
source link: https://bajie.dev/posts/20230301-hubot_dingding/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Hubot集成企业钉钉

2023-03-01 2 分钟阅读

换了公司,现在的公司用的是钉钉,不是企业微信,那么 hubot 就得改接入钉钉了

前文回顾:Hubot集成企业微信+jenkins+ansible

不明白的可以先看那一篇,那么首先的步骤是一样的,同样要去钉钉开放平台,用管理员登录:

https://open.dingtalk.com/

登陆后,点击应用开发–>企业应用开发:

image-20230301105804714

然后应用开发,机器人,点击创建应用:

image-20230301105903419.png

建好后,点击应用信息,可以看到应用凭证

我们记录下来 AppSecret,之后要用到

image-20230301110516010

然后再点击开发管理,这里需要你把 hubot 的服务器地址给公布出去,需要有个公网地址

因为hubot是监听的8080端口,所以映射是 xxxx.ip:80 –> hubotip:8080

服务器出口 IP 的地方 , 需要在 hubot 的服务器上,curl http://ipinfo.io ,得到地址,然后填上(我们的 ip 非常特殊,每一次访问都有可能会换个ip,所以只好把整段填写进去,而且把公网映射ip也填进去)

消息接收地址填上映射后的地址:https://bot.rendoumi.com/hubot/dingtalk/message/(用不用nginx加证书变https随具体情况定)

image-20230301105958063

然后去hubot安装dingtalk插件,在hubot安装根目录运行

npm install hubot-dingtalk

export HUBOT_DINGTALK_AUTH_TYPE=sign
export HUBOT_DINGTALK_SECRET=xxxxxxxxxx
export HUBOT_DINGTALK_MODE=1

./bin/hubot -a dingtalk

然后我们去用浏览器访问 https://bot.rendoumi.com/hubot/dingtalk/message/,会返回这个

image-20230301132914868

然后就可以了。至于把 hubot 做成服务,就参考上一篇文章,把jenkins和ansible都加上,做一个好用的机器人。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK