Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You will have to install a small Java program (SvnFeeder) to poll the Subversion server and send the commit comments and list of files to Svn Gateway.
The configuration is done in a simple XML file:

Single repository

Code Block
languagexml
titleconfiguration file example
<svn_feeder_configuration>
   <svn_repository key='ip...21' stop_on_copy='1' first_rev='-1'>
       <url>https://xxx.example.com/svn_dev</url>
       <username>xx</username>
       <password>xx</password>
   </svn_repository>
</svn_feeder_configuration>

Optional attributes:

  • stop_on_copy: set to 1 or 0. For details about usage, please refer to Subversion documentation
  • first_rev: Use this attribute if you only want to have the last part of a branch to be used for the synchronization. If the attribute is not present, SvnFeeder will take the whole branch

...

SvnFeeder is launched with the following command:

Code Block
languagepowershell
titlecommand line
java -jar SvnFeeder.jar -c configfile [-loop][-reset]

 

Optional arguments

  • -loop: when specified, SvnFeeder will stay in memory and run an update every minute
  • -reset: if specified, SvnFeeder will start by requesting Svn Gateway to remove all known data about the repositories described in this configuration file. 
    This is useful if you change from one repository to another, or from a trunk to a branch

...

  • Ensure you have Java 7 or higher installed
  • Download SvnFeeder.zip
  • Create a folder for installation
  • Unzip SvnFeeder.zip content in that folder
  • Edit the configuration file
  • Run the feeder:

    Code Block
    java -jar SvnFeeder.jar -c configfile -loop &

    this will run the SvnFeeder in the background, and update Svn Gateway every minute. Then you can call this script from /etc/rc.local for example under Linux.

You can also use the post-commit technique to launch this tool only after each repository commit. 
See a description of the steps below on this page

...

If you chose to use the Intranet mode, the configuration file you write will then look like this:

Code Block
languagexml
titleconfiguration files example
<svn_feeder_configuration>
   <svn_repository key='ip...21'>
       <url>https://xxx.example.com/svn_dev</url>
       <username>xx</username>
       <password>xx</password>
       <nick>Dev</nick>
       <svn_viewer>http://10.0.0.45/SvnViewer/svn_dev/rev/</svn_viewer>
   </svn_repository>
   <svn_repository key='ip...21/2'>
       <url>https://xxx.example.com/svn_marketing</url>
       <username>xx</username>
       <password>xx</password>
       <nick>Marketing</nick>
       <svn_viewer>http://10.0.0.45/SvnViewer/svn_marketing/rev/</svn_viewer>
   </svn_repository>
</svn_feeder_configuration>

The same optional attributes described above can be used for each repository

...

If you want the force your users to enter a commit comment containing a valid JIRA issue key in each commits, you can do so by using the following recipe
Note that our customers only experienced this with a Linux installation, as described in this tutorial. We can work with you if you need to do this under Windows.

  1. Add this code to the pre-commit file on the subversion server:

    Code Block
    REPOS="$1" 
    TXN="$2" 
    TMP=`mktemp` 
    /usr/bin/svnlook log -t $TXN $REPOS > $TMP 
    java -jar /pathtosvnfeeder/SvnFeeder.jar -c /pathtoconfigfile/configFile -checkjira "$REPOS" "$TMP" || exit1

    where:

    • pathtosvnfeeder is the absolute directory to the SvnFeeder java program
    • and pathtoconfigfile the absolute directory to the SvnFeeder configuration file.
    This is the only mandatory step. When you've done this, the subversion server will call our SvnFeeder utility before each commit and SvnFeeder will send a request to our add-on asking if the JIRA issues keys detected in the commit message exist.
    • If at least one of such key is found the commit is accepted
    • otherwise it is refused.
  2. If you have want to restrict the choice of JIRA projects to only a list of projects, you can add the following XML element in the configuration file:

    Code Block
    <svn_feeder_configuration>
       <pre_commit projects='X,Y,Z' />
       <svn_repository key='ip...21'>
                ...
       </svn_repository>
    </svn_feeder_configuration>

    with X,Y,Z the list of projects you want to allow. All other projects will not be accepted. If a commit contains at least one of the authorized projects's existing issues, the commit will be accepted. 

  3. If you have many repositories, with one or more JIRA project matching each repository, you can add the following marking in the configuration file to specify the correspondence:

    Code Block
    <svn_feeder_configuration>
       <svn_repository key='ip...21'>
           <pre_commit projects='X,Y,Z' local_svn='pathtosvn' />
                ...
       </svn_repository>
    </svn_feeder_configuration>

    Note that in this case the pre_commit element is inside the svn_repository element. You can specify different pre_commit elements for every subversion repository. 

    In order for the matching to work, you also need to add the local_svn attribute: it must contain the server local path to the repository 
    One of our customers has 40+ repositories, and one JIRA project for each repository. They just added a pre_commit element to each of their repository to ensure that commits cannot be done to the wrong project.
  4. Restriction on JIRA status: you can also add that only some JIRA issues status are accepted when you commit. 
    This is also done with a pre_commit XML element but this time with the status attribute:

    Code Block
    <svn_feeder_configuration>
       <pre_commit projects='X,Y,Z' status='Open,In Progress' />
       <svn_repository key='ip...21'>
                ...
       </svn_repository>
    </svn_feeder_configuration>

    In this case, only the issues with status Open or In Progress are accepted by the pre-commit. The status attribute is independent of the projects attribute. Both can be specified globally or by project.

  5. If you have other special requests for the pre-commit rules, we can probably manage to implement them, don't hesitate to come back to us.

...

You can use SvnFeeder in a smarter way than the -loop attribute that will ping the subversion server every minute. 
Add this code to the post-commit file on the subversion server:

Code Block
java -jar /pathtosvnfeeder/SvnFeeder.jar -c /pathtoconfigfile/configFile 

...

where:

  • pathtosvnfeeder is the absolute directory to the SvnFeeder java program
  • and pathtoconfigfile the absolute directory to the SvnFeeder configuration file.

...

Don't hesitate to contact us to assist in the installation.