For Setting up PHP project you need to install the following plugins for Jenkins:
- DRY (for processing phpcpd logfiles in PMD-CPD format)
- PMD (for processing PHPMD logfiles in PMD format)
- Warnings (for processing PHP compiler warnings in the console log)
The following PHP tools are required:
We assume that these tools are on the $PATH and can be invoked with phpunit, phpcs, phploc, pdepend, phpmd, phpcpd, and phpdox, respectively. For instance because you have downloaded the respective PHP archives (PHAR) and put them into your $PATH or because you have installed the tools globally using composer.
We use Apache Ant to automate the build process. It orchestrates the execution of the various tools in the build.xml build script (download). The build script assumes that the rule sets for PHP_CodeSniffer and PHPMD are located at build/phpcs.xml and build/phpmd.xml.
Executing the build.xml script will produce the following build directory:
|-- api ...
|-- coverage ...
These build artifacts will be processed by Jenkins.
Using the Job Template
$ cd $JENKINS_HOME/jobs (NOTE : $JENKINS_HOME will be /var/lib/jenkins/)
$ mkdir php-template
$ cd php-template
$ wget https://raw.github.com/sebastianbergmann/php-jenkins-template/master/config.xml
$ cd ..
$ chown -R jenkins:jenkins php-template/
Now Do the following steps –
- Click on “New Job”.
- Enter a “Job name”.
- Select “Copy existing job” and enter “php-template” into the “Copy from” field.
- Click “OK”.
- Uncheck the “Disable Build” or “Disable this Project” option.
- Fill in your “Source Code Management” information.
- Configure a “Build Trigger”, for instance “Poll SCM”.
- Click “Save”.
The Money project is an example that uses the build automation.
Use 1-3 steps same as above steps and in step-4 select “git” in Source Code Management and add Repository URL – https://github.com/sebastianbergmann/money.git and you can also configure many options there according to your need, then Click on “Save”. See reference screeshot –
Now click on “Build Now” to check whether the build is successful or not. You can see console output in Build History section.
For more information you can see here – http://jenkins-php.org/