Jenkins CI: how to run builds on SVN commits

What plugins and plugin functions do I need to install in order to get my Jenkins task to run the build code at any time that is tied to the SVN project? I installed both the standard SVN plugin and the plugin for SVN tags, but I don’t see any new features that allow you to configure the trigger.

+62
svn continuous-integration jenkins jenkins-plugins
Apr 04 2018-12-12T00:
source share
5 answers

There are two ways to do this:

First, I recommend the first option because of its ease of implementation. After you mature in your assembly processes, switch to the second.

  • Interrogate the repository to see if any changes have occurred. This can “skip” the commit if two commits fall within the same polling interval. For a description of how to do this , take a look at the fourth screenshot in which you configure the “build trigger” task based on a repository poll (with a configuration similar to crontab).

  • Set your repository to hook after commit, which notifies Jenkins of the need to create an assembly. A description of how to do this here is in the “Captures after committing” section.

The SVN tag function is not part of the survey, it is part of moving the current "header" of the source code to the tag to take a snapshot of the assembly. This allows you to reference Jenkins buid # 32 as an SVN tag / tags / tags / build-32 (or something similar).

+69
Apr 04 2018-12-12T00:
source share

I created a tool using python with some bash to start jenkins build. Basically you need to collect these two values ​​from post-commit when the commit gets to the svn server:

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

Then you use "svnlook dirs-changed $ 1 -r $ 2" to get the path just passed. Then you can check which repository you want to build. Imagine you have one hundred thousand projects. You cannot check the entire repository correctly?

You can check my script from github

I wrote this script since I just learned python and still use it now. I planned to improve it, but new projects and things just hold me back all the time. Everyone with good python knowledge certainly has the best built-in tool. If anyone could share, would like to have it.

0
Aug 19 '15 at 14:50
source share

Do you guys recommend GitHub run builds instead of SVN? Actually, I just know SVN, but I wonder why so many people choose to use GitHub.

0
Oct 16 '17 at 3:52 on
source share

You only need one plugin, which is a subversion plugin. then Just go to jenkins-> job_name-> Build Trigger section → (i) Trigger the trigger remotely (i.e. from scripts) Authentication ID: -Token_name

Then go to the svn server hooks directory, then after the fire under the commands: - (a) cp post-commit.tmpl post-commit (b) chmod 777 post-commit (c) chown -R www-data: www-data post- commit (d) vi post-commit Note: All lines should be commented out add the last line of syntax (for linux user): - / usr / bin / curl http: // username: API_token @ localhost: 8081 / job / job_name / build? token = Token_name

Syntax

(for Windows users): - C: / curl_for_win / curl http: // username: API_token @ localhost: 8081 / job / job_name / build? token = Token_name

0
Oct 18 '17 at 6:31 on
source share

You can use the post-commit hook.

Put the post-commit script hook in the hooks folder, create a wget_folder on your C: \ drive and put the wget.exe file in this folder. Add the following code to a 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 = job name

echo used to view the value, and you can also add exit 2 at the end to find out about the problem and whether the post-commit script is working or not.

-one
Apr 01 '16 at 11:56 on
source share



All Articles