Objective:
Good! After the subversion installation that ended up with the previous blog tutorial. We started the next job, the implementation of the SVN post-commit under the Windows version. To tell the truth, this knowledge on the Internet is not a lot of ~~~~~~~.
What is >>>post-commit for?
When the user implements a commit, the contents of the corresponding Post-commit file are executed. Automatic triggering when a commit is implemented.
>>> where should this post-commit.bat file be placed?
Well, the problem depends largely on the directory location where you choose to install repository when you install VISUALSVN server. This is the case if you choose the default installation location C:\Repository.
After you create the corresponding repository under VISUALSVN server, if you create a warehouse named Test. Then the corresponding test repository will be generated under your C:\Repository.
OK, now put your Post-commit.bat file in the C:\Repository\test\hooks directory.
================================================================================
Good. The following need to implement the corresponding Post-commit.bat file function. Of course, everyone's needs are different. I am here to extract the corresponding SVN data, and then through the Curl tool
Post the corresponding data to the corresponding URL.
Here is the Post-commit.bat I have written, you can use as a reference (of course ~. ~, here you have to familiarize yourself with the batch processing of Windows ..... ):
@echo on::Place the file in the Hooks directory of SVN repository, such as D:\subversion\test\hooks::1. The name must be Post_commit::2. Modify the SVN hooks in case where curl is the Easyops application pipelineSETLogfile=c:\post-commit.LogSETrepos=%1SETrev=%2SETTxn_name=%3::UUIDSvnlook uuid%repos% >. \data.txtSET/P uuid=<. \data.txt::AUTHORSvnlook author%repos%-R%rev% > \data.txtSET/P author=<. \data.txt::LOGSvnlook Log%repos%-R%rev% >. \data.txtSET/P log=<. \data.txt::DATESvnlookDate%repos%-R%rev% >. \data.txtSET/PDATE=<. \data.txtEcho%repos%%rev%%txn_name%%uuid% >>%logfile%::==================================================:: ChangeSvnlook changed%repos%-R%rev% > \data.txt for/F "delims="%%i in (. \data.txt) Do(Setchange=%%i) & (GotoEXIT_CHANGE_FOR): Exit_change_for::TYPE for/F "tokens=2 delims="%%t in ("%change%") Do for/F "Tokens=1 delims=/"%%c in ("%%t") Do Set TYPE=%%c::TAG for/F "tokens=2 delims="%%t in ("%change%") Do for/F "tokens=2 delims=/"%%c in ("%%t") Do Settag=%%c::======================================================Echo"Judge from%change%, type is%type%" >>%logfile%::according to the application requirements, fill in the Easyops svn hook URL in different types, if you do not differentiate the branch, then fill in the *)if"%type%" = = "trunk"GotoLabel_trunkif"%type%" = = "tags"GotoLabel_tagif"%type%" = = "Branchs" (GotoLABEL_BRANCHS)Else GotoLabel_all: Label_trunkSETUrl= "http://r.easyops.cn/hook/subversion/org/1888/app/5ac9dd6f01ca7/pipeline/4dc5522c75d5d5e68e5b0d89925c3802"GotoExit_type: Label_tagsSETUrl= ""::url= ' http://admin.easyops.local/hook/subversion/org/1888/app/598beb9fbcc06/pipeline/ 85df75da575635744a1f2feefa913a61 'GotoExit_type: Label_branchsSETUrl= ""GotoExit_type: Label_allSETUrl= "" &&GotoExit_type: Exit_typeif"%url%" = = "" (Echo"Not found trigger URLs in%type% TYPE, exit" >>%logfile% &&Exit0)Else Echo"Would trigger%url%" >>%logfile%::replace the \ \ for win down path. Otherwise there will be formatting problemsSetrepos=%repos:\=\\%Setrev=%rev:\=\\%Settxn_name=%txn_name:\=\\%Setuuid=%uuid:\=\\%Settag=%tag:\=\\%Setauthor=%author:\=\\%Set DATE=%DATE:\=\\%Set TYPE=%TYPE:\=\\%::Generate_post_dataSetPost_data= "{\" repos\ ": \"%repos%\ ", \" rev\ ": \"%rev%\ ", \" txn_name\ ": \"%txn_name%\ ", \" uuid\ ": \"%uuid%\ ", \" type\ ": \ "%type%\", \ "tag\": \ "%tag%\", \ "author\": \ "%author%\", \ "date\": \ "%date%\"} "SetCurl=c:\curl.exe%curl%-i-x post-h"Content-type:application/json"--data%post_data%%url%View Code
Place the appropriate Post-commit.bat file in the appropriate warehouse hooks directory
=============================================================================
The following is the test Post-commit implementation effect ....
(1) First checkout the test repository created under the VISAULSVN server to the desired directory. (Click the right mouse button to see the corresponding SVN checkout operation)
(2) After the end of checkout, add or update the corresponding files or directories in the copy test repository.
(3) After completing the above operation, the right mouse button found the SVN commit operation, and then click on the implementation.
Of course there are all kinds of bugs here. Still needs to be solved.
Implementation of SVN post-commit under Windows