[LNMP automation integration] use jenkins for PHP continuous integration-automated code check, analysis, and Singleton testing

Source: Internet
Author: User
Tags php continuous integration
[LNMP automation integration] use jenkins for PHP continuous integration-automated code inspection, analysis, and Singleton testing continuous integration to solve problems
  1. Uniform test code release
  2. Code automated testing
  3. Multi-host automatic deployment
Tool selection
  1. Integrated tools jenkins official http://jenkins-ci.org/
  2. Build tools phing official http://www.phing.info/
Jenkins + php installation (Linux environment, default php5.3)
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.reporpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.keyyum install jenkinsyum install javayum install java-1.6.0-openjdkyum install phpyum install php-develyum install php-pearyum install re2cyum install php-pecl-imagickyum install php-domyum install php-pear-phingyum install php-phpunit-PHPUnityum install php-phpunit-phpcpdpear channel-discover pear.phpmd.orgpear install --alldeps phpmd/PHP_PMD
Configure and start jenkins

Service jenkins startchkconfig jenkins on

Jenkins configuration Extensions required for jenkins installation (online web extension installation)

Role Strategy (Role-based permission management) Publish Over SSH Plugin (Publish code through ssh) Phing (php build tool) PMD (code static check) PlotJDependDRY

Role-Based permission management

Use the Role Strategy plug-in to implement permission management. choose system management> Manage and Assign Roles.

Project prefix + regular expression matching can be used to manage permissions of the project team.

Publish code through ssh (password-free input)
  1. Create a user production machine on the production machine, that is, the machine that runs the program, and receive the code uploaded from the jenkins deployment machine through ssh.
    useradd jenkins_publisher
  2. Generate a public/private key on the publisher, that is, the machine where jenkins is located.
    Keygen-t rsa (select all) and then find the public/private key in/root/. ssh/
  3. Send the public key to the publisher
    1. Transfer/root/. ssh/id_rsa.pub on the publishing machine to/home/jenkins_publisher/. ssh/2. change id_rsa.pub to authorized_keys3. set authorized_keys to jenkins_publisher
  4. Create a program directory on the production machine
    [First deployment] create the corresponding package directory: mkdir-p/data/svn_data/chown-R jenkins_publisher/data/svn_data/(based on the actual deployment environment) [each application deployment] create the corresponding web program directory: mkdir-p/data/www/*** (based on the actual deployment environment) to change the directory owner: chown-R jenkins_publisher/data/www /***
  5. Jenkins configures the ssh source through password-free configuration of the ssh source (copy the private key generated in the previous step). The login account is jenkins_publisher.

    Released to production machine

Create a jenkins project Build file Template

Add the build. xml file to the svn root directory of the program.

  #### Program directory (changed based on actual conditions)
  #### Integration and build related configurations
  #### Php code scale analysis tool configuration
  #### Php code static check tool configuration
  #### Php code analysis tool configuration
  #### Php Singleton test configuration
  #### Build parameter configuration
  #### Build parameter configuration
Jenkins package code configuration

Packaging configuration

Configure ssh release for jenkins (executable shell)

Publish directory configuration

Code release
  1. Update code to svn
  2. In this jenkins project, operate "Build Now"
  3. Check the current build-console output. The status is as follows:

Build result

Release Rollback
  1. Roll back the code on svn to the previous stable version and submit the code (it must be a submission, not just a local file rollback)
  2. Re-build code
  3. Data rollback

Sorted in 2015/02

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.