Jenkins – Setting up a PHP project in jenkins
- Digital Engineering
Jenkins – Setting up a PHP project in jenkins
Pre-requisites –
For Setting up PHP project you need to install the following plugins for Jenkins:
- Checkstyle (for processing PHP_CodeSniffer logfiles in Checkstyle format)
- Clover PHP (for processing PHPUnit‘s Clover XML logfile)
- HTML Publisher (for publishing documentation generated by phpDox, for instance)
- JDepend (for processing PHP_Depend logfiles in JDepend format)
- Violations (for processing various logfiles)
- 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.
Automation –
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:
1 2 3 4 5 6 7 8 9 10 11 12 |
build |-- api ... |-- coverage ... `-- logs |-- checkstyle.xml |-- clover.xml |-- crap4j.xml |-- jdepend.xml |-- junit.xml |-- phploc.csv |-- pmd-cpd.xml `-- pmd.xml |
These build artifacts will be processed by Jenkins.
Integration –
Using the Job Template
1 2 3 4 5 6 |
$ 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”.
Example –
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/
Related content
Auriga: Leveling Up for Enterprise Growth!
Auriga’s journey began in 2010 crafting products for India’s