Jenkins_Setup

Michal Čihař edited this page Aug 8, 2016 · 5 revisions

Install Jenkins

You can install Jenkins using their Debian repository for automatic installation and updates.

  • Add repository key to your system

wget -q -O -https://jenkins-ci.org/debian/jenkins-ci.org.key| sudo apt-key add -

  • Add these lines at the end of your /etc/apt/sources.list

## Jenkins CI debhttp://pkg.jenkins-ci.org/debianbinary/

  • Now you can install Jenkins using apt-get

sudo apt-get update sudo apt-get install jenkins

  • Be sure this pulls in Sun Java, Jenkins fails to work with OpenJDK. You will also need a JDK installed, JRE is not enough.

Or download latest debian package from http://mirrors.jenkins-ci.org/ And install using dpkg

sudo dpkg -i jenkins_1.413_all.deb

Additional Packages

Dont forget to install required packages to get code from Git repo and build with Apache Ant.

  • Git

sudo apt-get install git # (on older systems the package is called git-core)

  • Apache Ant

sudo apt-get install ant

Testing Environment

Make sure that you have configured TestingEnvironment correctly.

  • You can quick check this by verifying phpUnit version

phpunit --version

Should be 3.5.13 or greater.

  • And try to run phpUnit tests

phpunit -c phpunit.xml.nocoverage

Getting plugins

First you need to update your installed plug-ins. Go to the Plugin Manager http://localhost:8080/pluginManager/ and update existing plugins.

Then you need to install additional plugins for Jenkins

  • Git plugin (to get sources from git repo) 1
  • Clover or Clover PHP Plugin (for processing PHPUnit logs) 2, 3
  • HTML Publisher Plugin (for publishing PHPUnit html reports) 4
  • Checkstyle Plugin (for processing PHP_CodeSniffer logs) 5
  • Violations (for processing checkstyle and pmd logs) 6
  • PMD Plugin (for processing pmd logs) 7
  • DRY Plugin (for processing phpcpd logs) 8
  • JDepend Plugin (for processing PHP_Depend logs) 9
  • xUnit Plugin (for processing phpunit logs in junit format) 10

You can install this plugins using Jenkins web interface

http://localhost:8080/pluginManager/available

Or using Jenkins CLI:

wgethttp://localhost:8080/jnlpJars/jenkins-cli.jar

  • Install needed plugins

java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin git java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin clover java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin cloverphp java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin htmlpublisher java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin plot java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin checkstyle java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin violations java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin pmd java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin dry java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin jdepend java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin xunit

  • Also you may install some additional useful plugins

java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin saferestart java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin dashboard-view java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin jquery java -jar jenkins-cli.jar -shttp://localhost:8080install-plugin jquery-ui

  • Restart Jenkins

java -jar jenkins-cli.jar -shttp://localhost:8080safe-restart

Installing additional required PHP Tools

To run code analysis you need to install additional PHP code analyzers. Like PHP_Depend and PHP_PMD.

  • Add additional PEAR channels

sudo pear channel-discover pear.pdepend.org sudo pear channel-discover pear.phpmd.org sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear channel-discover pear.netpirates.net

  • Install packages

sudo pear install pdepend/PHP_Depend sudo pear install phpmd/PHP_PMD sudo pear install PHPDocumentor sudo pear install PHP_CodeSniffer sudo pear install -a phpunit/phpcpd sudo pear install phpunit/phploc sudo pear install -a phpunit/PHP_CodeBrowser sudo pear install -a phpunit/PHPUnit

Build configuration

Working sample of ant build xml file you can be found in Git (as build.xml).

And sample phpunit.xml can be found in Git (as phpunit.xml.dist).

Jenkins Jobs

You can define Jenkins jobs in the Jenkins interface.

Category:Devel

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.