background
- The team forgot to write the weekly report, how to do, every Friday manual ait all?…
- I just gave you a Mr, close it for me
- Need to keep track of the packaging and deployment platform progress every release?
.
The solution
Automation! Automation! Automation! The above problem solving can be divided into two types: scheduled tasks and triggering of a specific event
Enterprise wechat/Dingpin supports the addition of group robots. The robots will correspond to a Webhook address. By calling this address, the group robots will send message content (text/Markdown format), supporting @ all the people in the group or group members.
- [Scheduled task] The server runs the scheduled task and calls the webhook address of the swarm robot
- Trigger a specific event (the event needs to support a custom Webhook that is the interface address), and the back-end interface calls the robot Webhook address
For example, git push supports custom webhooks. When the code has push, the filled webhooks will be called
👇 simple draw a flow chart, better understand a bit
Graph LR code push - > fill in callback interface | | carrying parameters of backend interface will receive parameters assembly into new - > | | call enterprise WeChat group of robot webhook address run time task node layer - > | | call enterprise WeChat group of robot webhook address
1) Webhook address parameter format of enterprise wechat group robot 👇
2) The parameter example of the code push callback 👇, as shown in the figure, contains the information of the project and this submission. We can perform data integration and call the webhook address of the enterprise wechat group robot
{
"object_kind": "push"."before": "95790bf891e76fee5e1747ab589903a6a1f80f22"."after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7"."ref": "refs/heads/master"."checkout_sha": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7"."user_id": 4."user_name": "John Smith"."user_username": "jsmith"."user_email": "[email protected]"."user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b 6bd6?s=80"."project_id": 15."project": {"id": 15."name":"Diaspora"."description":""."web_url":"http://example.com/mike/diaspora"."avatar_url":null."git_ssh_url":"[email protected]:mike/diaspora.git"."git_http_url":"http://example.com/mike/diaspora.git"."namespace":"Mike"."visibility_level":0."path_with_namespace":"mike/diaspora"."default_branch":"master"."homepage":"http://example.com/mike/diaspora"."url":"[email protected]:mike/diaspora.git"."ssh_url":"[email protected]:mike/diaspora.git"."http_url":"http://example.com/mike/diaspora.git"
},
"repository": {"name": "Diaspora"."url": "[email protected]:mike/diaspora.git"."description": ""."homepage": "http://example.com/mike/diaspora"."git_http_url":"http://example.com/mike/diaspora.git"."git_ssh_url":"[email protected]:mike/diaspora.git"."visibility_level":0
},
"commits": [{"id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327"."message": "Update Catalan translation to e38cb41."."timestamp": "2011-12-12T14:27:31+02:00"."url": "http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327"."author": {
"name": "Jordi Mallach"."email": "[email protected]"
},
"added": ["CHANGELOG"]."modified": ["app/controller/application.rb"]."removed": []}, {"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7"."message": "fixed readme"."timestamp": "2012-01-03T23:36:29+02:00"."url": "http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7"."author": {
"name": "GitLab dev user"."email": "gitlabdev@dv6700.(none)"
},
"added": ["CHANGELOG"]."modified": ["app/controller/application.rb"]."removed": []}],"total_commits_count": 4
}
Copy the code
action
- Node layer as back-end service; Egg is recommended to support scheduled tasks
- Group robot Webhook address that calls enterprise wechat for scheduled tasks
- The push of the project code triggers A push event that calls back the Webhook address (the default Node service interface A address). Interface A processes the parameters passed by push event and invokes the webhook address of group robot in enterprise wechat
- After package success/failure, preset script (curl interface B address), interface B call enterprise wechat group robot address
Q & A
Q- You may want to say: isn’t there a weekly report prompt on enterprise wechat every Friday? A- The reporting tips are uniform. Each group may have customization and may also have A requirement to write A daily paper
Q- Mr And packaging, deployment platform packaging can be set after the email alert, unnecessary? A- My friends around me are not so dependent on email, and they use wechat/Dingpin more. My idea is to make such auxiliary tools as little as possible, so that developers can concentrate more
The results of
- Every Friday 18:40 timing push to write weekly news to the group, and all the aite
- The code push sends a message to the group and atters the submitter, displays the submission information, and so on
- After the code is packaged and deployed, it sends messages to the group and aits everyone
conclusion
- Thinking about how to [slack off] and reduce repetitive work
- Automate as much of your work as possible to add a little fun to the roll