Sunday, June 10, 2012

Easy start with Jenkins for PHP developer

Lets look into the quick and minimal Jenkins setup for middle sized fast growing PHP project.
In order to easy follow this article you should at least:
  • have PEAR installed on server
  • use phpUnit for unit tests
  • build your app with Phing
Install Jenkins according to the operation system you have.

On my Ubuntu 12.04 LTS its only four CLI commands:
# wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
# sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
# sudo apt-get update
# sudo apt-get install jenkins

Jenkins will be available under http://localhost:8080/ by default.

Go to "Manage Jenkins" > "Manage Plugins" in order to install plugins required for PHP project:

  • Phing - run Phing targets
  • xUnit - parse phpUnit log files

For more information look into Jenkins for PHP website OR really awesome book Integrating PHP Projects with Jenkins.

Now when all plugins are installed we can configure our project.

Click "New Job", input job name, select "Build a free-style software project" and click "OK"

New Job is created and you will be redirected to Job configuration page.
First of all you should configure project working directory. In order to do that you should find "Advanced Project Options" section and expand it by clicking "Advanced..." button.

Check the "Use custom workspace" checkbox and input the path to your project root directory.

Its good to configure your build process to checkout the code from SVN, but in order to simplify our current setup we will describe that in next article, so lets just leave "None" in "Source Code Management" section.

Also in "Build Triggers" section we will check "Build periodically" checkbox and set the nightly build with the cron-like syntax: "0 0 * * *". 
NOTE: The whole point of Continuous Integration is to perform tests and build on any change (commit to version control system) but not on some periodical basis. So in the future its good to configure the VCS and use "Poll SCM" instead that will for example once per 5 minutes check it there were any new commits and only then will start the build process.



PERMISSIONS DISCLAIMER: Jenkins operates from under its own user, so make sure you've applied your permissions configuration accordingly.

From this point you can save the configuration and click "Build Now" in order to execute empty build.
In build log you will see something like:

Started by user anonymous
Building in workspace /home/joseph/www/aaaaa.localhost
Finished: SUCCESS


Click "Configure" link and lets fill our build with "Build" and "Post Build Actions".
Lets assume that our Phing file looks as simple as this build.xml:



<project name="name-of-project" default="build">
  <property name="basedir" value="." override="true" />
<target name="build" depends="alltests">
    <!--  deploy your project here -->
 </target>

<target name="alltests" depends="prepare">
 <phpunit haltonfailure="true" haltonerror="true" printsummary="true">
 <formatter todir="${basedir}/build/tests" type="xml"/>
 <batchtest classpath="${basedir}/tests/">
    <fileset dir="${basedir}/tests">
              <include name="*.php"/>
            </fileset>
         </batchtest>
     </phpunit>
 </target>

 <target name="clean" description="Cleanup build artifacts">
  <delete dir="${basedir}/build/tests"/>
 </target>


 <target name="prepare" depends="clean" description="Prepare for build">
  <mkdir dir="${basedir}/build/tests"/>
 </target>

</project>


So we have a very simple set of tasks to build, test and deploy our web application.

Click "Add Build Step" in "Build" section and select "Invoke Phing targets".
Input the name of the target you want to execute, i. e. "build" (you can even specify couple of them  separated by space)

Click "Add post-build action" in "Post-build Actions" section and select "Publish JUnit test result report". Input for example "build/tests/*.xml" as we've configured in build.xml file to store logs in such location.



Click "Save" and start build.
Yahoo! We are all set!

Next time we will talk about integration with version control systems and try a lot of interesting things like codding standard compliance checkcode complexity measurement, copy-paste detection, code dependency analysis and API documentation generation. See ya!

42 comments:

  1. I like your post because when customers hire Hire PHP Developers so he should know all the tactics about PHP because customer will ask you anything.

    ReplyDelete
  2. These articles and blogs are genuinely sufficiency for me for a day.
    Web Development

    ReplyDelete
  3. Jenkins is an open source continuous integration tool written in Java. It is a server-based system running in a servlet container such as Apache Tomcat. It supports SCM tools including CVS, Subversion, Git, Mercurial, Perforce and Clear case.Thanks For Sharing this Information.

    Hire PHP Developer

    ReplyDelete
  4. It is possible to use PHP in almost every operating system. PHP can be used in all major operating systems including Linux, Microsoft Windows, Mac OS X, and RISC OS.

    php developer india

    ReplyDelete
  5. Great blog!The information you provide is quiet helpful, why I was not able to find it earlier. Anyways I’ve subscribed to your feeds, keep the good work up.

    PHP developer

    ReplyDelete
  6. Hello sir, How are you today?

    Outstanding one. Very important website on webdevbyjoss.blogspot.com described here which is definitely actual.It is a like able website.Many people are getting various advantages by this website. I think men should take notice on it.Really, I really like this site I am going to demonstrate you how to make a web page in WordPress in less than 10 min. I will show How to create a website. Wordpress platforms is a free foundation (free) web page designer which you can handle online. You will learn how Easy it is to set up WordPress, along with simple guidelines on "How to make some primary options in WordPress." But first, you will need to make web host with HostGator. In it clip I have defined this detailed.

    Thanks for attractive Article.

    ReplyDelete
  7. Really awesome post .. It is really informative and quality of the content is extraordinary.
    This is perfect blog for anyone who is looking for topics like this. It has got it all, information, benefits and overview thanks for sharing this post.

    vacheldaniel
    PHP Development Team
    http://cmscentral.net/

    ReplyDelete
  8. Firstly thanks a lot for such a wonderful post. I would like to know more about such topics and hope to get some more helpful information from your blog. C U soon.
    PHP Developer Chicago

    ReplyDelete
  9. It's great stuff. Each and every day i learn some new information through your blog.It's really helpful to me in my PHP project.
    PHP Developer Chicago

    ReplyDelete
  10. The main purpose of preparing Abu Dhabi Web Design responsive layout is to have a particular set of codes that runs smoothly on all environments.

    ReplyDelete
  11. While designing it is necessary to keep website requirement in mind. The prerequisite designing help in content and web pages sequencing.
    Web Design Companies

    ReplyDelete

  12. I show up record it. I ache for to catch included this topic…i am respecting the time and fulfillment you put in your site....

    by MGT 521 Week 5 provider


    ReplyDelete
  13. Jenkins makes the project able to built in more than one way. It maintains a continuity of tools so that they can be used without any error. I will follow your steps to access the Jenkins.

    php developer india

    ReplyDelete

  14. This is a nice article..Its very easy to understand ..And this article is using to learn something about it..
    by MGT 521 Week 1 provider

    ReplyDelete
  15. I desire to express gratitude you for this informative read; I actually appreciate for sharing this large post......
    by HomeworkHelp provider

    ReplyDelete
  16. i want to learn more php language and i want to be genius in designing !!! can you tell me where i find good sources to learn more about php language and design.
    Mohamed Elhosary,
    http://homeneedit.com

    ReplyDelete
  17. a essay editor will certainly transform your own essay coming from just as one ordinary good essay writing companies in uk in to an refined AS WELL AS concise essay. you employ probably spent the considerable variety connected with time a lot more than ones academic assignment. the then step can be to be able to polish This to perfection. This is possible intended for you, to be a writer, to help overlook ones errors so that you can have committed.

    ReplyDelete
  18. Well someway I got to read items of items on your blog. It’s amazing how interesting it is for me to visit you very often.
    by BCOM 275 Week 3 provider

    ReplyDelete
  19. PHP is good language for designing a web site and you have shared such a nice and informative information on PHP, Thanks for sharing.
    php development chicago

    ReplyDelete
  20. Great post on php and unique content you have used.

    Thanks

    rickybroad

    http://codal.com/

    ReplyDelete
  21. I am very joyous when read this blog mail because blog posted letters in writing in good kind and compose on good theme. by LAW 421 Entire Course provider

    ReplyDelete
  22. Standard vacationers call for discounts and other cheap small business routes. The reason being they will journey over a day-to-day foundation. Several air routes firms contemplate these vacationers although many do not.discount travel

    ReplyDelete
  23. Hello there, You've done an incredible job. I'll certainly digg it and for my part recommend to my friends. I am confident they will be benefited from this site.
    Hire Magento Developers

    ReplyDelete
  24. world-wide-web design transactions by the area regarding designing a great site IN ADDITION TO with the extended perform updating AND ALSO maintaining. with the internet boom, every business wants to have the online footprint IN ADDITION TO the site is actually The best way to showcase one's skills ALONG WITH institution AND kindle the curiosity regarding potential customers.CMS for web designers

    ReplyDelete
  25. I saw your post and this post is really informative for PHP Development and i think every developer should follow this.

    Thanks

    Ricky Broad

    http://codal.com/

    ReplyDelete
  26. I’m leveraged. You’re really well acquainted and very brilliant. You created certain thing that people could comprehend and made the subject Bewitching for every person.
    by MGT 350 Final Exam Provider

    ReplyDelete
  27. Great post . It takes me almost half an hour to read the whole post. Definitely this one of the informative and useful post to me. Thanks for the share. I also provide this service plz visit my site php development in delhi Elesoftech is a leading offshare web development.






    ReplyDelete
  28. very interesting to study I will come across further hooked on this! Keep it up. I found very good and relevant blog and have bookmarked your spot for prospect suggestions. BY - Need PHP Developer

    ReplyDelete
  29. Thanks for share this blog. Youyr blog is very informative. i will bokmark it Hire Best Python Django Programmers

    ReplyDelete
  30. Ways & Works Consulting is an ISO 9001:2015 certified HR Consulting Firm, Manpower Recruitment and Practical Training firm career with an aim to provide value aided service to employersTop Manpower Recruitement company in india . with an in-depth understanding of their requirements. We are working as a perfect bridge between the employer and employee to fulfil their needs by placing the best suitable at place.

    ReplyDelete
  31. Hello,
    I love your blog so much. i would like to inform you that there's plenty of good information on this blog, I loved to read it and I think people will get a lot more support from this blog. Thanks for sharing this informative blog, please keep it up and share some special posts with us in the future.
    about us
    Mobile app development companies in Bangalore
    we are also best Mobile app development company in Bangalore
    Mobile app development companies in India
    Mobile app development companies in India

    ReplyDelete
  32. This is a nice post in an interesting line of content.Thanks for sharing this article, great way of bring this topic to discussion.

    awesome post presented by you..your writing style is fabulous and keep update with your blogs.
    Mobile App Development Company in Bangalore
    Mobile App Development Companies in Mumbai
    Mobile App Development Company in Delhi
    Top Mobile App Development Companies in San Francisco
    Top Mobile App Development Companies in Chennai

    ReplyDelete
  33. Hi, I Read your blog and I feel it is a very wonderful, informative blog . There are a lot of good information on this blog, I'd like to Share and I think people will get a lot of support from this blog. Thank you for sharing this informative blog, please keep up and share some unique posts with us in the future.
    Mobile App Development Company in India
    Mobile App Development Company in bangalore
    Mobile App Development Company in chennai
    Mobile App Development Company in kolkata
    top agencies
    packers and movers

    ReplyDelete
  34. The advancement of technology has positively influenced the growth of businesses all over the planet. With the help of modern technologies like websites and mobile applications, every firm can sell its products or services online without hassle. We, QuikieApps, have acquired recognition and reputation through the reliance of our respected clients as the top Web development company. Also Quikieapps is the top front-end development company and flutter app development company in Bangalore, India, USA, UK, Dubai. Adapting the dynamic technology of the web and mobile applications is the first step to success in this modish and competitive world.

    ReplyDelete
  35. Social Beat is a digital growth partner for hyperscaling startups & top brands - Google Premier Partner, Preferred Facebook Marketing Partner. By digital marketing company in IndiaThe Best digital marketing agency in India which not only offers SEO, PPC, SMM, Branding but also provides 360° online marketing.

    Free Job Alert site is for Government,Sarkari Naukri,Banks,Railways,Police Recruitment, Results of IBPS,UPSC,SSC,RRB, Fresher IT Jobs and Walkins.

    How can I contact a match? What can I do with a free membership? How do I cancel my Premium subscription? Getting started - Read more: Elite Singles Contact Information:

    Qualified interior designers Gorakhpur has, will always ensure that the quality of work delivered is as per the expectations of their clients. Visit Now: Interior Designer in Gorakhpur, UP

    ReplyDelete
  36. Even if your company has an internal software development team, the app you’re looking to build may not match your team's skills, and you may need a freelance app developer with relevant qualifications. It’s time-consuming and often more expensive to build AI-based or AR features without relevant expertise.
    Hire a top-rated freelance app developer on the emerging freelance marketplace Eiliana.com and get high-quality deliverables on time.

    ReplyDelete