Webhooks

Before getting started on today’s topic, let me talk about Webhooks.

I used a third-party payment aggregator called ping++ (www.pingxx.com) a long time ago.

After the user completes the payment, we push the payment result to our own server via “Webhooks”, then we can continue to do the order completion and so on.

“Webhooks”, which push “some data” that we care about to the receive link that we define “some node” to continue.

Or on Github, someone sends you an issue, and it automatically triggers this Webhooks message that sends it out. You just need to define the interface to receive the issue.

In many places “Webhooks” have become “hubs” that need, or may need, to provide customization for subsequent operations, and have always been a favorite concept of mine.

Code monitoring system based on SVN + nail

Take back one of the things we wanted to do today: how to build our code monitoring system using SVN Webhooks, plus pegswarm robots.

I’m sure you already know what I’m going to do, just get to the point.

svn Webhooks

In real development, many enterprises or companies basically use Github, domestic code cloud, coding. IO and other code hosting platforms, or use GitLab to build code version control based on Git. However, many use SVN for version control.

In SVN, there are also multiple Webhooks:

Currently SVN provides five hooks, focusing on the following three:

hook meaning parameter
start-commit It runs before a commit transaction occurs and is usually used to determine whether a user has the right to commit The path to the repository, and the user name to commit to
pre-commit Run before the transaction has completed the commit, usually this hook is used to determine if the submitted information does not meet the requirements to allow the commit The path to the repository and the name of the transaction being committed
post-commit It runs after the transaction completes, creating a new revised version Most use this hook to send descriptive emails about the submission or as a backup of the version library. This paper mainly uses this hook to push information to the peg group as the source of monitoring

A detailed description of concrete can refer to website: SVN version management, rounding www.kancloud.cn/i281151/svn…

Note: The SVNlook command is a good tool for viewing various SVN versions

Spike swarm robots

With SVN hooks, we need an “interface” that receives hooks data, and our first concern as monitoring is that we receive messages in real time whenever a colleague submits code.

There are many such tools for receiving messages in the market, such as Zero message, Slack, BearyChat, wechat template message, enterprise wechat, Dingdinggang robot and so on; As long as the message is delivered to our phones in real time.

This article mainly recommends the use of “nail nail group 🤖”, mainly because it is simple, and does not need any “cost”, such as zero letter and other information restrictions and money; Template messaging and enterprise wechat all require the so-called Access token, which requires server development.

The Nailing robot, on the other hand, can “seamlessly” hook to SVN hooks without using anything.

Let’s take a look at how to create swarm robots:

1. Create your own “internal group chat” :

2. Build a robot

3. Select Custom.

4. Select add and randomly give the robot a name

After that, remember to copy the Webhook link for the robot, such as:

https://oapi.dingtalk.com/robot/send?access_token=0ca87986b61166d06a9a588c0f7ba648639208bd1f02971655fc5927b0620***
Copy the code

5. After the creation, the robot will send a message:

Now, with this link, we can combine post-commit with SVN to receive basic information about the commit.

Note: as for nailing group of robot Webhook how to use, you can refer to nailing website description: open-doc.dingtalk.com/docs/doc.ht…

Post – commit to nailing

This article implements the simplest monitoring: as long as a colleague submits the code, the information will be pushed to the pin group in time, so that all colleagues in the group can receive the push message in real time.

In this case, the SVN information in the post-commit file can be used to request the link of the robot group by post method.

HOOKS are the HOOKS that keep me connected to the robot payload.

Because different SVNS of different systems can use different scripting languages to write push codes, this paper is based on Linux, so shell scripting language is directly used.

Finally, you can try to see the monitoring effect I built before:

conclusion

In fact, Swarm robot is a Webhook. It transmits the information we need to know in real time to our phones, using Webhooks on a series of different services.

For example, in this system, a colleague commits the code -> SVN post-commit Webhook -> push the robot Webhook -> push to the group.

Because of the time, how to use Webhooks to maximize real-time monitoring and access to the information we need, this is what this article is about, I hope it will help you.

“Finished”


Coding01 looks forward to your continued attention