0

post-commit hook.ifファイルがビルドされたことをトリガしたい場合、 "SOURCE/databasescript"ディレクトリにコミットされ、ファイル名は "update.sql"です。svnコミットされたディレクトリのリストにファイル名が存在するかどうかを調べる

コミット後

set "REPOS=%~1" 
set "TXN=%~3" 
set "REV=%~2" 
echo "repos %REPOS%." >> C:\test.log 
echo "REV %REV%." >> C:\test.log 
echo "txn %TXN%." >> C:\test.log 
"%VISUALSVN_SERVER%\bin\svnlook.exe" changed -r %2 %1 >>C:\test.log 

出力

"repos D:\Repositories\TestNAPFServer." 
"REV 82." 
"txn 81-2e." 
U SOURCE/databasescript/basedb.sql 
U SOURCE/databasescript/update.sql 

私が提案したバッチfile.Pleaseにディレクトリリストでファイル名を検索するために条件を書く方法を知りません。私のためのソリューションの作業の下

答えて

1

ポストcommit.cmd

setlocal enabledelayedexpansion 
@echo off 
REM Get the current path 
set mypath=%cd% 

set "REPOS=%~1" 
set "TXN=%~3" 
set "REV=%~2" 
REM create log folder 
IF NOT EXIST %REPOS%\log (
    md %REPOS%\log\ 
) 
REM Delete the file log file 
del /F /Q %REPOS%\log\napfposthook.log 
echo "Current path-%mypath%" >> %REPOS%\log\napfposthook.log 
echo "repos %REPOS%." >> %REPOS%\log\napfposthook.log 
echo "REV %REV%." >> %REPOS%\log\napfposthook.log 
echo "txn %TXN%." >> %REPOS%\log\napfposthook.log 
set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe" 
%SVNLOOK% changed -r %2 %1 >> %REPOS%\log\napfposthook.log 

Set SEPARATOR=, 
SET COMMENT= 

REM Concatenate all the lines in the commit message 
fOR /F "tokens=2 delims= " %%g IN ('%SVNLOOK% changed -r %REV% %REPOS%') do ( 
    set currentline=%%g 
    set COMMENT=!COMMENT!%SEPARATOR%!currentline! 
) 

REM Delete the file before insert the directory list 
del /F /Q %REPOS%\log\napfsearch.txt 

REM Write the all directory list into file 
echo %COMMENT% >> %REPOS%\log\napfsearch.txt 

REM Find the string into file 
find /I "update.sql" "%REPOS%\log\napfsearch.txt">nul 
set findStatus=%errorlevel% 
echo %findStatus% >> %REPOS%\log\napfposthook.log 


SET CSCRIPT=%windir%\system32\cscript.exe 
SET VBSCRIPT=D:\Repositories\post-commit-hook-jenkins-sam.vbs 
"%CSCRIPT%" "%VBSCRIPT%" "NAPF_PRODB" "f23338c8b8f7216fad54dd34da7a2a5d" "%findStatus%" 

ポストコミットフック・ジェンキンス-sam.vbs

Set args = WScript.Arguments 
JobName = args.Item(0) 
Token = args.Item(1) 
updateDbScript=args.Item(2) 
JenkinsServerUrl="http://10.254.6.206:8080/jenkins/" 

If updateDbScript = 0 Then 
    Wscript.Echo "Triggered the update job..." 
    updateUrl = JenkinsServerUrl+"/buildByToken/buildWithParameters?job=" + JobName + "&token=" + Token+ "&Type=1" 
    updateRequest = "" 
    'Sending rest request to jenkins 
    HTTPPost updateUrl, updateRequest 
else 
    Wscript.Echo "Triggered the jenkins main job..." 
    sUrl = JenkinsServerUrl+"/buildByToken/buildWithParameters?job=" + JobName + "&token=" + Token+ "&Type=0" 
    'POST Request to send.... 
    sRequest = "" 
    'Sending rest request to jenkins 
    HTTPPost sUrl, sRequest 
End If 


Function HTTPPost(sUrl, sRequest) 
    set oHTTP = CreateObject("Microsoft.XMLHTTP") 
    oHTTP.open "POST", sUrl,false 
    oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
    oHTTP.setRequestHeader "Content-Length", Len(sRequest) 
    oHTTP.send sRequest 
    HTTPPost = oHTTP.responseText 
End Function 
関連する問題