Integrate ZenTao with Git
- 2015-09-14 11:29:35
- azalea
- 8370
- Last edited by xiying guan on 2018-12-06 10:10:29
1. Git integration mechanism
The basic mechanism of Git integration is to analyze comments of code submission =>get related stories, tasks and bugIDs => write it to the database of ZenTao.
There are two ways todo what have been mentioned above. One is the hook built in Git. When the code is submitted, the hook scripts will be triggered. Then it will analyze comments and obtain bugs, stories or task IDs. Then write revelant records into the database by calling API in ZenTao. The other way is log commands on Git. With the commands, you can get all the submitted records and then generate IDs through analysis. Finally, write them into the database.
2. Deploy git command-line client on the machine installed with ZenTao
GIT command-line client refers to Git commands built in Git. It is git.exe in Windows and git in Linux.The machine installed ZenTao can be separated from that of subversion. They don’t have to be installed in the same machine.
You have to install Git for machines of linux system; Git for rhel and centos with yum and apt-get install for Debian.
3. Configure Git in ZenTao
3.1 Codes
The Configuration file of Git is saved in zentao/module/git/config.php. You can modify this file and it is recommended that the modified version be saved in git/ext/config/git.php. In this way, future update will not override the configuration file.
3.2 Configuration
As for setting subversion parameters, there are concepts involed as follows.- Position of the Git client command
- Repo: multiple repos can be set.
Now let’s see specific examples
3.2.1 Find the location in a red box in the image below.
3.2.2 Modify code
Write codes as the examples show:
$config->git->client // the path to fill in git client
$config->git->repos[$i]['path'] // the path to fill in git repo
3.3 Set multiple repos
3.3.1 As in the case above, you can find the following codes in the same file.
3.3.2 Modify Code
- Delete “/*”and”*/“from the code and other modifications are as shown above. Notes: $i ++ cannot be modified.
- For any git repos, copy the code and configure in the same way.
4. Comment format of submitting code
When developers submit to Git, they need to specify modification relevant stories, tasks or bug IDs in the notes in the following format.bug#123,234, 1234 or bug: 123,234 1234; comma or space can be used as pace holders in ID lists;
story#123; task#123.
Bugs, stories and tasks must be labeled.
5. Execute Git synchronizing command
5.1 Refer to Chapter
8.1.1 Intialize Scripts to initialize all the scripts of the command line.5.2 Enter the directory of zentao/bin/ and execute syncgit.bat or syncgit.sh.
5.3 The screenshot of executing the scripts.
5.4 Check bugs.
6. Deploy scheduled tasks
6.1 When all the commands are deployed, add the commands to the scheduled tasks. For example, execute the task every 5 minutes. Use scheduled tasks in Windows and crontab in Linux.6.2 The code repository configured has to be synchronized with the scheduled tasks and use Git pull every 5 minutes.