Jenkins CI: How to trigger builds on SVN commit

前端 未结 4 1467
误落风尘
误落风尘 2020-12-02 06:16

What plugins and plugin features do I need to set in order to get my Jenkins job to trigger a build any time code is committed to an SVN project?

I have installed bo

4条回答
  •  自闭症患者
    2020-12-02 06:52

    You can use a post-commit hook.

    Put the post-commit hook script in the hooks folder, create a wget_folder in your C:\ drive, and put the wget.exe file in this folder. Add the following code in the file called post-commit.bat

    SET REPOS=%1   
    SET REV=%2
    
    FOR /f "tokens=*" %%a IN (  
    'svnlook uuid %REPOS%'  
    ) DO (  
    SET UUID=%%a  
    )  
    
    FOR /f "tokens=*" %%b IN (  
    'svnlook changed --revision %REV% %REPOS%'  
    ) DO (  
    SET POST=%%b   
    )
    
    echo %REPOS% ----- 1>&2
    
    echo %REV% -- 1>&2
    
    echo %UUID% --1>&2
    
    echo %POST% --1>&2
    
    C:\wget_folder\wget ^   
        --header="Content-Type:text/plain" ^   
        --post-data="%POST%" ^   
        --output-document="-" ^   
        --timeout=2 ^     
        http://localhost:9090/job/Test/build/%UUID%/notifyCommit?rev=%REV%    
    

    where Test = name of the job

    echo is used to see the value and you can also add exit 2 at the end to know about the issue and whether the post-commit hook script is running or not.

提交回复
热议问题