programing

PHP 프로젝트를위한 배포 / 빌드 / CI주기 설정

new-time 2020. 5. 9. 10:57
반응형

PHP 프로젝트를위한 배포 / 빌드 / CI주기 설정


저는 대부분의 시간에 고독한 개발자이며 주로 PHP 기반의 많은 대규모 프로젝트를 수행하고 있습니다. 코드베이스의 변경 사항을 처리하는 방법을 전문화하고 자동화하고 근본적인 변경없이 팀에서 작업 할 수있는 지속적인 통합 프로세스를 만들고 싶습니다.내가 지금하고있는 일은 모든 프로젝트에 대해 로컬 테스트 환경이 있다는 것입니다. 각 프로젝트마다 SVN을 사용합니다. 변경 사항은 로컬에서 테스트 한 다음 일반적으로 FTP를 통해 온라인 버전으로 전송됩니다. API 문서는 소스 코드에서 수동으로 생성됩니다. 단위 테스트는 느리게 진행되고 있으며 아직 일상적인 일이 아닙니다.내가 계획하고있는 "빌드주기"는 다음을 수행합니다.

  • 로컬에서 테스트 한 후 변경 세트가 SVN에 체크인됩니다.
  • 빌드 프로세스를 시작합니다. SVN HEAD 개정판이 체크 아웃되고 필요한 경우 수정되며 업로드 준비가되었습니다.
  • API 문서는 자동으로 생성됩니다. 기본 템플릿을 사용하여 아직 자세히 설정하지 않은 경우 전체 코드베이스를 스캔합니다.
  • 새로운 개정판은 FTP를 통해 원격 위치에 배포됩니다 (일부 디렉토리 이름 바꾸기, chmodding, 데이터베이스 가져 오기 등 포함). 이것은 이미

    피싱

    좋아하는 것이지만 물론 대안을 위해 열려 있습니다.
  • 사전 정의 된 위치에있는 단위 테스트가 실행됩니다. 전자 메일, RSS 또는 웹 페이지에 넣을 수있는 HTML 출력 (바람직하게는)을 사용하여 실패 또는 성공에 대한 정보를 받았습니다.
  • (선택 사항) 사전 정의 된 위치의 최종 사용자 "changelog"텍스트 파일이 커밋 메시지의 사전 정의 된 부분으로 업데이트됩니다 ( "이제"foo "와"bar "를 모두 동시에 필터링 할 수 있음) 이 메시지는 SVN 커밋 메시지와 반드시 같을 필요는 없으며, 여기에는 아마도 더 많은 내부 정보가 포함되어있을 것입니다.
  • 코드 메트릭스, 코드 스타일 검사 등과 같은 것들이 현재 제 주요 초점은 아니지만 장기적으로는 확실합니다. 이 즉시 사용 가능한 솔루션은 매우 친절합니다.

내가 찾고 있어요

  • 비슷한 상황에 있거나 비슷한 상황에있는 사람들의 피드백과 경험에 대한 솔루션을 성공적으로 구현했습니다.
  • 특히,

    단계별 자습서 및

    이를 설정하는 방법에 대한 연습
  • 예를 들어, 각각의 새 프로젝트에 대한 스켈레톤 API, 테스트 케이스 등을 작성하여

    최대한 많은 자동화

    를 제공하는 솔루션 .

그리고 또한

  • 제품 권장 사항 . 내가 지금까지 알고있는 것은 빌드를 위한 phing / ant ,보고 부분을위한 phpUnderControl 또는 Hudson 입니다. 나는 그들이 볼 수있는 한 그들을 모두 좋아하지만 물론 그들에 대한 자세한 경험은 없습니다.

나는 일로

늪에 빠졌

으므로 간단한 해결책에 대한 강한 성향을 가지고 있습니다. 반면에 기능이 누락 된 경우 기능이 너무 제한되어 있습니다. :) 포인트 앤 클릭 솔루션도 환영합니다. 또한 PHP 프로젝트와 함께 사용할 수있는 상용 제품 권장 사항도 있습니다.

내 설정

나는 Windows에서 로컬로 (정확히 말하면 7) 작업하고 있으며 대부분의 클라이언트 프로젝트는 LAMP 스택에서 실행되며 종종 공유 호스팅 (= 원격 SSH 없음)에서 실행됩니다. 내 환경에서 실행할 수있는 솔루션을 찾고 있습니다. 이를 위해 Linux VM을 설정할 준비가되었습니다. 문제 없습니다. 호스팅 솔루션은 설명 된 모든 측면을 제공하거나 프로세스의 다른 부분과 상호 작용할 수있을 정도로 융통성이있는 경우에만 유용합니다.

현상금

나는 가장 많은 마일리지를 줄 것이라고 생각하는 대답을 받아들이고 있습니다. 여기에 훌륭한 의견이 많이 있습니다. 하나 이상의 답변을 받아 들일 수 있기를 바랍니다. 모두 감사합니다!

나는

buildbot

,

CruiseControl.net

,

CruiseControl

Hudson

겪었습니다 . 내가 CruiseControl *을 정말로 좋아했지만, 복잡한 의존 사례가 너무 번거로 웠습니다. buildbot은 설정하기 쉽지 않지만 멋진 분위기가 있습니다 (파이썬을 좋아하는 것이 전부입니다). 그러나 허드슨은 다음과 같은 이유로 이전 세 가지를 이겼습니다.

  1. 설정하기 쉽습니다.
  2. 쉽게 사용자 정의 할 수 있습니다
  3. 좋아 보이고 개요 기능이 훌륭합니다.
  4. 자체 및 설치된 모든 플러그인에 대한 포인트 앤 클릭 업데이트가 있습니다. 이것은 정말 좋은 기능입니다. 점점 더 감사합니다.

경고 : 위에서 언급 한 빌드 서버 (CC.net은

모노에서

실행 됨 )의 기본으로 Linux를 사용 했지만 문서에 따르면 크로스 플랫폼을 실행해야합니다.

허드슨 서버 설정

전제 조건 :

  • Java (1.5는 잘 작동합니다)
  • Subversion 서버에 대한 읽기 권한 (허드슨 사용자를위한 별도의 계정이 있습니다)

여기서부터는 다음과 같습니다.

java -jar hudson.war

이렇게하면 콘솔에서 작은 서버 인스턴스가 바로

http://localhost:8080

실행되므로 해당 포트에서 미리 실행중인 다른 항목이없는 경우에 설치를 찾아 볼 수 있어야합니다 (

--httpPort=ANOTHER_HTTP_PORT

옵션을 전달하여 다른 포트를 지정할 수 있음) . 위의 명령) 및 모든 것이 '설치'프로세스에서 잘 진행되었습니다.사용 가능한 플러그인 디렉토리 (

http://localhost:8080/pluginManager/available

)로 이동하면 위에서 언급 한 작업을 지원하기위한 플러그인이 있습니다 (기본적으로 서브 버전 지원이 설치됨).그것이 식욕을 자극하면

tomcat

또는

jetty

와 같은 Java 응용 프로그램 서버를 설치해야합니다 . 모든 주요 응용 프로그램 서버에 대해

설치 지침

을 사용할 수 있습니다

업데이트

:

Kawaguchi Kohsuke

hudson 용

Windows 서비스 설치 프로그램

구성했습니다.

허드슨에서 프로젝트 설정

다음 연습의 링크는 실행중인 hudson 인스턴스가 있다고 가정합니다.

http://localhost:8080

  1. http://localhost:8080/view/All/newJob왼쪽 메뉴에서 새 작업 ( )을 선택하십시오
  2. 작업에 이름을 지정하고 Build a free-style software project목록을 확인하십시오.
  3. Pressing 'ok' will take you to the configuration page of the job. All the options have a little question mark besides them. Pressing this will bring up a help text regarding the option.
  4. Under the option group 'Source Code Management' you would be using Subversion. Hudson accepts both url access as well as local module access
  5. Under the option group 'Build Triggers', you would use 'Poll SCM'. The syntax used here is that of cron, so polling the subversion repository every 5 minutes would be */5 * * * *
  6. The process of building the project is specified under the option group 'Build'. If you already have an ant build file with all the targets you need, you're in luck. Just choose 'Invoke ant' and write the name of the target. The option group supports maven and shell commands as well out of the box, but there is also a plugin available for phing.
  7. Tick off additional build actions in 'Post Build Actions', such as e-mail notifications or archiving of build artefacts.

For setting up processes for which hudson have no plugins, you can either call them directly through a shell script from within the build setup, or you could write you own plugin

Pitfalls:

  • If you have it produce build artefacts, remember to have hudson clean up after itself in regular intervals.
  • If you have more than 20 projects set up, consider not displaying their build status as the default main page on hudson

Good luck!


The term you are looking for is "continous integration."

Here is an example of someone who uses GIT + phpundercontrol: http://maff.ailoo.net/2009/09/continuous-integration-phpundercontrol-git/

CruiseControl (which is a CI server), can use Hosted SVN/GIT as a source. So you can even use it with GitHub or Beanstalk or something else.

Then you can integrate that with the following kind of software:

  • PHPUnit
  • php-codesniffer
  • phpdocumentor
  • PHP Gcov
  • PHPXref
  • Yasca
  • etc.

You could also try this hosted CI: http://www.php-ci.net/hosting/create-project

Keep in mind though, that those tools need custom support if you integrate them yourself.

Have you also thought about project management and patch management?

You can use Redmine for project management. It has integrated continuous integration support, but only as client side (not as CI server).

Try using a hosted SVN/GIT/etc. solution, because they will cover your backups and keep their servers running, so you can focus on development.

For a tutorial on how to setup Hudson, see: http://toptopic.wordpress.com/2009/02/26/php-and-hudson/


I use Atlassian's Bamboo continous integration server for my main PHP project (along with their other products such as fisheye (repository browsing), jira (issue tracker) and clover (code coverage)).

It supports SVN and now supports Git and it has a great user interface. It is available for linux, windows and mac and can run standalone on its own tomcat server which is great for people (like me) who does not like to take days to setup their tools). Although it may look expensive, being a lone developer myself I purchased the starter kit license for 10$ (10$ by software). This is great for small teams and it is worth the look.


PHPTesting PHPCI This is nice, continuous integration server built in php.

Plus, its free and open source. :)

it has number of plugins..

PHPCI includes integration plugins for:

  • Atoum
  • Behat
  • Campfire
  • Codeception
  • Composer
  • Email
  • Grunt
  • IRC
  • PHP
  • Lint
  • MySQL
  • PDepend
  • PostgreSQL
  • PHP Code Sniffer
  • PHP Copy/Paste Detector
  • PHP Spec
  • PHP Unit
  • Shell Commands
  • Tar / Zip

I am mostly a sys admin but sometimes I code PHP as well. As a side project I created some scripts that will make it simple and painless to set up a full blown PHP CI environment using Jenkins. It also runs a sample project for you so you can see how each build step is configured.

If you want to try it out all you need is a Debian/Ubuntu box and shell access.

http://yauh.de/articles/379/setting-up-a-ci-environment-for-php-projects-using-jenkins-ci

Update To add some content to my answer:

You can simply set up a Jenkins CI for PHP using Ansible. Since v1.4 it supports roles which you can download from their galaxy.ansibleworks.com community site and it will do the heavy lifting for you. It is called jenkins-php.


I would suggest using Jenkins http://jenkins-ci.org/ it's free and it's open source.

It's pretty straight forward to setup, works on multiple platforms and integrates well with other continuous integration tools like SonarQube (+ SQUALE) to measure technical debt and Thucydides for testing automation.

I would highly suggest using GIT or GIT Hub for version control instead of SVN. From my point of view it's just a better version control system that will help you scale your development efforts later.

Since you're working mostly with PHP project there are some other tools you can use.

PHPUnit - For unit testing

PHP CodeSniffer - Check for coding standards

PHP Depend - Shows your PHP code dependencies

XDEBUG - For performance testing

All of these tools and be triggered with a Jenkins job and helps with the quality and performance of your code.

Good luck and Enjoy!


I do not use many of the products, or even types of products that you use, but I will give you my experience.

I run a TEST environment in parrallel with my PROD environment. I have no local testing per se. If it is too hard to get soemthing up into a real TEST environment, then I fix my build process. I don't see the point in testing locally, as the environments are different. UPDATE: The only thing I do locally is run "php -l" before I upload anything. Stops the stupid mistakes.

The build process works with whatever is in the current workspace, which includes uncommitted code. This is not everyone's cup of tea, but I am going to TEST very often. Everything gets committed before going to PROD.

Part of my build process (similar to yours) creates two META files. One contains the last (typically) 100 changes and also gives me the current changelist number. The shows me what changes are installed. The other contains the CLIENTSPEC (in Perforce terms) which shows me exactly what branches were used in this build. Together these give me reproducible builds.

I do not build straight to the target environment, but to a staging area on the server. I use SSH so this makes sense. This gives me a few advantages. Most importantly it avoids dying half way through a large upload. It also gives me a place to store META files, and all the build files are automatically archived (so I can go straight back to any build). The script also logs the update (so there is an entry in the log stream and I can see pre- and post-) and kicks all daemons (I use daemontools so "svc -t"). All of these are better off on the target machine.

One other issue is DB changes. I keep a master script of the DB schema, which I update every time the schema changes. Each of the changes also go into a changes.sql script, which is uploaded with the build to the staging area. The script is run as part of the install script.


I've recently begun the same kind of process, and am using Beanstalk for svn hosting.

There are two nifty features in the paid accounts (start at $15pm i think):

  • deployment allows the user to create ftp targets for staging and production servers, which can be deployed at the click of a button (inc specifying a revision and branch)
  • webhooks allow the user to set up a url that is called on each commit/deploy, passing across things like revision number, description and user. This could be used to update docs, run unit tests and update changelogs.

I'm sure there are other hosted or self-hosting svn servers with these two features, but beanstalk is the one i have experience of and it's working very, very well

There's also an API, which I imagine could be used to integrate deployment further in to your process.


Consider fazend.com, a free hosted CI platform, which automates configuration and installation procedures. You don't need to setup version control, bug tracking, CI server, test environment, etc. Everything is done on-demand.

참고URL : https://stackoverflow.com/questions/2180460/setting-up-a-deployment-build-ci-cycle-for-php-projects

반응형