Versions Compared

Key

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

...

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.recipes:

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

    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

    For Windows with VisualSVN (code contributed by Antenor):

    Code Block
    set REPOS=%1 
    set TXN=%2 
    set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe" 
    set SVNFEEDER= "pathtosvnfeeder\SvnFeeder.jar" 
    set FEEDERCONF= "pathtoconfigfile\SvnFeederConfig.xml"  
    set TEMP=%VISUALSVN_SERVER%jira%TXN%.log 
    %SVNLOOK% log -t %TXN% %REPOS% >  "%TEMP%"  
    java -jar %SVNFEEDER%  -c %FEEDERCONF%   -checkjira "%REPOS%" "%TEMP%"  
    if %errorlevel% gtr 0 (goto error_exit) else goto normal_exit 
    :error_exit 
    del "%TEMP%"  
    exit 1  
    :normal_exit 
    del "%TEMP%"  
    exit 0


    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.

...