I. Jenkins installation and configuration are not here. I mainly build Jenkins + ant + checkstyle in windows. Jenkins is the installation package. After installation, install ant and checkstyle in Plug-in management.
Ii. Install the PHP environment: codesniffer is a PHP code compliance check tool. It requires the support of PHP and pear before installation. We should first install the PHP environment. I am using phpstudy. Install it on drive D. Start Apache and MySQL after installation. And add the PHP Directory to the system environment variables. My directory is: D: \ phpstudy \ PHP.
3. Install pear: first download the go-pear.phar file to D: \ phpstudy \ PHP. CMD enter the command line, enter the directory, execute the PHP go-pear.phar one way press enter, and finally a line of prompt, let double-click the generated registry file, in D: \ phpstudy \ PHP find phppear_env.reg, double-click the installation button.
4. Install codesniffer: Download The PHP_CodeSniffer-1.4.5.tgz to decompress it to D: \ phpstudy \ PHP, CMD to enter the D: \ phpstudy \ PHP Directory to execute pear install php_codesniffer one way press Enter.
* ** If the installation fails, the following two commands may be useful to you: pear uninstall php_codesniffer (uninstall codesniffer) pear clear-Cache (clear error record information cache)
The above is ready to start Jenkins Configuration:
1. Create a new job and select to build a free-style software project named php_test
2. Source Code Management ----- subversion ---- repository fill in the svn address to be checked out (requires permission authentication), and fill in SRC in the local Module Directory
3. Build ---- select invoke ant ----- advanced ----- Build File fill in build. xml
4. perform post-build operations ------- select publish checkstyle analysis results ------- checkstyle results and fill in build \ logs \ checkstyle. xml
After saving, A php_test folder has been generated in jobs under Jenkins.
5. Build the file first. It should fail, but the file in the svn address will be checked out. And generate a workspace. The cause of the failure is that build. XML is not found. Copy the build. xml file to the workspace to change some configurations. The standards directory under codesniffer is the code style and Zend is used. The reports directory under codesniffer contains several report modes. For detailed configuration, you can download the build. xml file.
6. Because you want to use checkstyle, put the checkstyle-author.xsl file under workspace, This is the format file of the checkstyle report, re-execute the build successful, if the mail is configured, the mailbox should be able to receive the report.
Download tool: the above required tools can be downloaded here: http://download.csdn.net/detail/lxlmj/5770075
Note: The PHP_CodeSniffer-1.5.0RC2 cannot write checkstyle. XML, the solution is as follows:
PHP_CodeSniffer-1.5.0RC2 \ codesniffer \ reporting. php line 186th
Replace $ filename = $ reportfile; with $ filename = getcwd (). '/phpcs-'. $ report. '. tmp ';
D: \ phpstudy \ PHP \ phpcs
Replace include_once 'php/codesniffer/CLI. php'; with include_once 'php _ CodeSniffer-1.5.0RC2/codesniffer/CLI. php ';