svn implements DingTalk code submission notification

Time:2022-11-24

Welcome to join the front-end exchange group:749539640

In fact, svn also has its own hooks like github, let’s look at the effect first

svn implements DingTalk code submission notification

DingTalk robot configuration (generated by webhook)

Settings => Add Robot

svn implements DingTalk code submission notification

Add a custom robot, add keywords here#can

svn implements DingTalk code submission notification

copy webhook

svn implements DingTalk code submission notification

svn settings

When we enter the server code directory of svn, we will see a hooks folder

svn implements DingTalk code submission notification

Currently svn provides 5 hooks, today we only introducepost-commitreference

It runs after the transaction completes, creating a new revision. Most people use this hook to send descriptive emails about commits, or as a backup of the repository. The repository passes the program two arguments: the path to the repository and the new revision number to create. Exiting the program is ignored.

Next, we enter the hooks folder and execute

vim post-commit

If not, this file will be created automatically

type code

#!/bin/bash
# Variable 1 in svn is the warehouse path, and 2 is the submission version number

REPOS="$1"
REV="$2"

# Set the default character set, otherwise the Chinese characters will be garbled when the post information arrives on DingTalk
export LANG=en_US.UTF-8

# The svnlook command below gets the corresponding result
time=$(date +%F/%T)
AUTHOR=$(/bin/svnlook author -r ${REV} ${REPOS})
CHANGEDDIRS=$(/bin/svnlook dirs-changed $REPOS)
MESSAGE=$(/bin/svnlook log -r $REV $REPOS)

CONTENT=Submit time: ${time}\\nSubmit version: #${REV}\\nSubmit by: ${AUTHOR}\\nSubmit note: ${MESSAGE}\\nModify directory: $CHANGEDDIRS
curl 'https://oapi.dingtalk.com/robot/send?access_token=Enter your webhooks token here' \
   -H 'Content-Type: application/json' \
   -d '{"msgtype": "text",
        "text": {
             "content":"'$CONTENT'"
        }
      }'

Let me talk about the security settings when DingTalk webhoos was generated#number and the submitted version in the above code#corresponding up

The final test result is the picture at the beginning of the text! Every time the code is submitted, the postcommit hook will be triggered to automatically push the information to DingTalk

Recommended Today

vue-cli3.0 configure Iview custom theme

don’t panic, followIviewCome on, probably . . . no problem! 1. Create a new my-them.less @import ‘~view-design/src/styles/index.less’; /*Theme configuration and other configurations refer to https://github.com/view-design/ViewUI/blob/master/src/styles/custom.less*/ @primary-color: #6C86FF; @link-hover-color: #6C86FF; 2. Import the entry file main.js import ‘./assets/css/my-them.less’; illustrate The less file needs to be supported here, and the project should install less and less-loader // […]