svn is associated with redmine (not redmine is associated with svn)

The requirements are as follows:
1. The project structure must be refactored. Cut to maven
2. The code must have multiple branches (currently only trunk)
3. The code submission must be associated with redmine, which is used to regulate that the development of the current version cannot be submitted that does not belong to the current stream Tasks. Serve for multiple branches of code. (Development that is not familiar with this development method is easy to make mistakes in branches)

The method is:
use the svn hook Insert picture description here
pre-commit hook,
call the redmine python plug-in in the hook,
request the result, and then determine whether it is available to submit successfully
exit 1 block
exit 0 available to submit


Three parameters can be obtained in the process hook. The
Insert picture description here
first parameter (which library) plus the second parameter (submitted version number transaction) can uniquely determine that a certain submission
is a parameter of svnlook

https://www.cnblogs.com/wangjiyuan/p/svnnn.html

Insert picture description here
Note to use
E:\Program Files\VisualSVN Server\bin
instead
of svnlook in C:\Program Files\TortoiseSVN\bin

The hook code is as follows


set REPOS=%1
set TXN=%2

set AA= %STDIN
set SVN_BINDIR="E:\Program Files\VisualSVN Server\bin"

echo 提交时必须填写说明 1>&2
echo "%REPOS%" -t "%TXN%" 1>&2

echo 版本不对99 1>&2
echo "%AA%" 1>&2


::for /f "delims=" %%i in ('dir ') do set b=%%i
::echo b=%b%

::我也不懂,大意是 svnlook是查看当次transaction的提交信息.
::然后将执行的结果传给 check.py,然后开始python执行.
%SVN_BINDIR%\svnlook.exe log "%REPOS%" -t "%TXN%" | python %SVN_BINDIR%\check.py "......" 1>&2

::python 脚本里最后执行exit(x)  erorlevel 就是x
if %errorlevel% equ 0 (     

echo 000 1>&2

)
if %errorlevel% equ 1 (

echo 111 1>&2

)
if %errorlevel% equ 2 (

echo 222 1>&2

)

exit 1

Then the executed python script (not connected to redmine yet):

# coding=gbk
import re
import sys

input_file = sys.stdin
print(input_file)
print("666") #相当于java里的println, 会打到svn提交失败的原因中

for s in input_file:
    u = s.decode('GBK')
    print(u) #这里可以得到提交时写的备注,通过备注里的redmine号,确认是否可以提交,出错给出详细信息让用户改redmine或给提交备注

exit(2)

python connect redmine

https://python-redmine.com

redmine provides api

Temporary effect
Insert picture description here

2020-07-09 update:
python connect redmine code

# -*- coding: utf-8 -*-
from redminelib import Redmine
#https://python-redmine.com/index.html
redmine = Redmine('http://192.168.*****/redmine', username='****', password='*****')
project = redmine.project.get('*****')
print(project.id)
issue = redmine.issue.get(15320)#
print(issue.url)
print(issue.assigned_to)
print(issue.description)
print(issue.status)
#print(issue.closed_on)
print(issue.status)
print(issue.subject) # 

print('----------1-------')
#print(issue.custom_fields.getattribute('cf_50'))
print(issue.custom_fields.get('cf_50'))

print('---------2--------')

print(dir(issue.custom_fields ))

print('----------3-------')
print(issue.custom_fields.total_count)

#for num in range(0,25):
#    print(num)
#    print(issue.custom_fields[num]['value']) #分类模块

print(issue.custom_fields[0]['value']) #业务归属
    
print(issue.custom_fields[4]['value']) #分类模块
print(issue.custom_fields[5]['value']) #所属部门
print(issue.custom_fields[7]['value']) #所属BA
print(issue.custom_fields[13]['value']) #版本管理

print('----------4------')

print( dir(issue.custom_fields))
print('-----------5------')

print( dir(issue))

#print(project.issue.get('15320'))

Guess you like

Origin blog.csdn.net/wangduqiang747/article/details/107152740
svn