Skip to content

Instantly share code, notes, and snippets.

@mythril
Last active December 17, 2015 09:18
Show Gist options
  • Save mythril/5585910 to your computer and use it in GitHub Desktop.
Save mythril/5585910 to your computer and use it in GitHub Desktop.
Setting up Jenkins for PHP / Git

Install basic required stack (on top of Debian GNU/Linux 7.0 (wheezy) netboot)

including: pear, ant, a JDK & JRE, git, sudo, php5 command line, curl

su
apt-get install php5-cli git sudo default-jre-headless php-pear ant \
	openjdk-6-jdk curl libapache2-mod-php5
usermod -a -G sudo <user>
exit

Install Jenkins Jenkins Debian packages

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo echo "deb http://pkg.jenkins-ci.org/debian binary/" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install jenkins

a new system user named jenkins will be created a system service name jenkins will be created also

Install PHP QA Tools and phpDox jenkins-php.org

sudo pear config-set auto_discover 1
sudo pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox

Obtain your jenkins server's CLI interface

wget http://localhost:8080/jnlpJars/jenkins-cli.jar

Install jenkins plugins for use in PHP jenkins-php.org

java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin checkstyle \
cloverphp dry htmlpublisher jdepend plot pmd violations xunit

Install jenkins plugins for Git & Github

java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin git github
curl https://raw.github.com/sebastianbergmann/php-jenkins-template/master/config.xml | \
	java -jar jenkins-cli.jar -s http://localhost:8080 create-job php-template

Restart jenkins

java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart
Elaborate better later:
setup github keys
setup git username and email for jenkins user

put github project url in jenkins job
put github git url into git scm field in jenkins job

schedule poll scm

put build path in

describe basic directory structure
	build.xml
	build/phpcs.xml
	build/phpmd.xml
	src/
	tests/

limit phpcs & phpcs-ci's scope to php files

phpdox config needed [found here](http://stackoverflow.com/questions/15360733/jenkins-job-fails)
php5-xsl
pear channel-discover pear.netpirates.net
pear install -f theseer/phpDox
pear channel-discover nikic.github.com/pear
pear install -f nikic/PHPParser

a2enmod userdir
a2enmod php5
edit mods-available/php5.conf
	comment out userdir exclusion
service apache2 restart
pecl install xdebug
updatedb
locate xdebug.so
[edit php.ini, add xdebug](http://xdebug.org/docs/install#configure-php)
[Set xdebug options](https://netbeans.org/project_downloads/www/php/debug-setup-flowchart.pdf)

setup samba/sftp access to project area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment