-
Notifications
You must be signed in to change notification settings - Fork 329
Integrate SVN and Git
ZenTao users usually work on SVN and Git to
SVN has been integrated into ZenTao 2.2+, which makes it easy for users to view codes. The following will show you how to integrate SVN in ZenTao.
- The basic mechanism of Subversion integration in ZenTao is to
Analyze code comments submitted => Get linked story, task, and bug IDs => Write IDs to ZenTao database.
Users have two ways to do it. One is to use the hook built-in SVN. When the code is committed, a hook script is triggered. It will analyze the comments and get the IDs of the linked stories, tasks, and bugs, and then call ZenTao API and record it in the database. The other way is to use LOG command at SVN client to get all the committed code and analyzes it to get the IDs, and then save it in the database.
Either way has its pros and cons. The second way is used in ZenTao because it is easier to debug and more convenient to deploy. Besides, it can also analyze all the previous records with more flexibility.
- Deploy SVN command-line client on machines installed ZenTao
SVN command lines are to commands built-in SVN. It is svn.exe in Windows and svn in Linux. The machine that ZenTao is installed can be independent of that one SVN is installed. They don’t have to be installed on the same machine.
- Install svn for Linux machines. Subversion can be installed for rhel and centos via yum, and apt-get in Debian.
- The latest Windows one-click installation package has built-in svn.ex e in the directory of \xampp\silksvn.
- If you install SVN in Windows, download slilksvn and then install it.
- Configure SVN in ZenTao
3.1 Code locations
The Configuration file of SVN is saved in zentao/module/svn/config.php. You can modify it and save it to svn/ext/config/svn.php. So later it will not be overridden if updated.
3.2 Configuration
Parameters below are involved in configuring SVN.
- the SVN client
- repo: multiple repos can be set.
- Username and parameters of the repo
Example
Find the labeled with a red box in the image below.
Modify codes as shown below.
- $config->svn->client: save svn.exe, the client executable files
- $config->svn->repos[$i]['path']: the path to save SVN code
- $config->svn->repos[$i]['username']: save SVN login user name; Leave it blank if you don’t need to log in.
- $config->svn->repos[$i]['password']: save SVN login password
Set multiple repos
Modify the codes
- Delete “/”and”/“ from the code and modify it as mentioned above. Notes: $i ++ cannot be changed.
- For any svn repos, copy the code and configure it in the same way.
- The format of code comment
When committing codes to SVN, developers need to specify relevant stories, tasks or bug IDs of changes in the comments. Please follow the format below.
- bug#123,234, 1234 or bug: 123,234 1234; comma or space can be used as space holders among IDs;
- story#123; task#123.
- Bugs, stories, and tasks must be labeled.
- Synchronize SVN
- Refer to Initialize Scripts to initialize all the scripts of command lines.
- Enter zentao/bin/ and execute syncsvn.bat or syncsvn.sh.
- The execution is shown below.
- Check the linked bugs in ZenTao
- Git integration mechanism
The basic mechanism of Git integration is to
Analyze code comments committed => Get IDs of linked stories, tasks and bug => Write IDs to ZenTao database.
Users have two ways to do what has been mentioned above. One is to use the hook built in SVN. When the code is committed, a hook is triggered. Then its comments will be analyzed, and the IDs of a bug/story/task will be obtained. Then ZenTao API is revoked, and enter the data to the database. The other way is to use the log command via Git. The command will get the committed data, then analyze it to get the IDs, and then write it in the database.
Each way has its pros and cons. The second one is used in ZenTao, because it is easier to debug and more convenient to deploy. It is also more flexible and can be used to analyze all the previous records.
- Deploy GIT client on the machine installed ZenTao
GIT client refers to command lines built in Git. It is git.exe in Windows and git in Linux. Currently, ZenTao can only integrate Git repos store on the same machine which installs ZenTao. If it is a remote repo that you want to use, you have to clone that repo and update it regularly.
You have to install Git for machines of Linux system. Install Git via yum for rhel and Centos and apt-get install for Debian.
- Configure Git in ZenTao
3.1 Codes The configuration file of Git is saved in zentao/module/git/config.php. You can modify it and save it in git/ext/config/git.php as recommended, so the configuration file will not be overridden once updated.
3.2 Configuration
Before setting GIT parameters, there are concepts involved as follows.
- Git client path
- Repo: multiple repos can be set.
Now let’s see an example.
Example
Find the code in a red box as shown below.
Modify codes as shown below.
- $config->git->client // the address of Git client
- $config->git->repos[$i]['path'] // the path to Git repo
Set multiple repos.
- Delete “/” and ”/“ from the code and other modifications are the same as shown above. Notes: $i ++ should not be modified.
- For other Git repos, copy the code and configure in the same way.
- Comment
When committing codes to Git, a comment on changes in relevant stories, tasks or bug IDs is required. Please follow the format below to write the comment.
- bug#123,234, 1234, or bug: 123,234 1234. Either a comma or space is used as space holders.
- story#123 task#123.
- Bugs, stories, and tasks must be labeled.
- Git sync
5.1 Refer to Initialize Scripts to initialize all the scripts of the command line.
5.2 Enter zentao/bin/ and execute syncgit.bat or syncgit.sh.
5.3 The screenshot of executing the scripts.
5.4 Check linked bugs.
- Activate Cron
6.1 When all the command lines are deployed, add the commands to the cron. Go to Admin->System and activate cron for Git Sync.
- Solution 1: Login ZenTao, and go to Admin->Cron. Switch it on and then activate Sync Git scripts.
- Solution 2: Use the cron in Control Panel of Windows and crontab in Linux.
6.2 The repository configured has to be synchronized via the cron. Use Git PULL to update every 5 minutes.
If you want to know more about integrations with applications, click HERE.
ZenTao Application Lifecycle Management www.zentao.pm