[LNMP automation integration] use jenkins for PHP continuous integration-automated code inspection, analysis, and Singleton testing continuous integration to solve problems
- Uniform test code release
- Code automated testing
- Multi-host automatic deployment
Tool selection
- Integrated tools jenkins official http://jenkins-ci.org/
- 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)
- 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
- 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/
- 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
- 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 /***
- 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
- Update code to svn
- In this jenkins project, operate "Build Now"
- Check the current build-console output. The status is as follows:
Build result
Release Rollback
- 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)
- Re-build code
- Data rollback
Sorted in 2015/02