Child pages
  • Commit Gateway
Skip to end of metadata
Go to start of metadata

CVS Trigger

To configure the version control systems to trigger commit events, two step are necessary:

  1. A mechanism is needed which notifies when a commit has happended.
  2. We need to react to this notification accordingly

1. loginfo

For CVS the first mechanism can be implemented by editing the loginfo file, which executes abritrary scripts whenever cvs commit log information are sent. In addition it is possible to pass some parameters to the invoked script:

loginfo
ALL $CVSROOT/CVSROOT/postcommit.sh %{psv}

To call a script you have to state for which projects in the repository the script should be executed on cvs commit log events. In the sample code above, the script is executed for every project (ALL). Also you need to provide the script's path and name (e.g$CVSROOT/CVSROOT/postcommit.sh).

Since the postcommit script requires the path, filename and version of the file for which the commit log info event occured, you also need to pass them to the postcommit script (%{psv}).

2. postcommit-script

The second mechanism is implemented via a script which fires an http get request to the backend passing the required values.

Notify Commit Gateway script
#!/bin/sh
REPO='some_repository'
IFS=","
set – $1
PATH=$(echo "$1" | sed 's/.$//')
FILE=$2
VERSION=$3
/usr/bin/curl http://<serverlocation and port>/emi.commit.event.gateway/rest/commitevents.json/send/cvs/$REPO/$PATH/$FILE/$VERSION
#Eat extra input
 /bin/cat > /dev/null

Basically this script only fires a http get request to the provided url in which serverlocation and port need to be substituted by your local values. But since the backend service retrieves the file via the provided webinterface of viewvc, you need to provide the root repositoriy name of the viewvc url (e.g. REPO='some_repository', assuming your root repository is located unter http://your.url/viewvc/some_repository). The other required parameters (path, filename, version) are just extracted from the passed input. Because they were concatenated with a comma (e.g. path/to,filename.pdf,1.00), the script first needs to split this input:

Splitting File information
IFS=","
set – $1
PATH=$(echo "$1" | sed 's/.$//')
FILE=$2
VERSION=$3

As you may notice, PATH isn't just assigned with $1 (i.e. the first part of the splitted input), but also its last character is deleted. This is necessary since some CVS servers may add an additional white space along with the path. If this is not the case in your installation you need to change this.

  • No labels