Skip to content

fufu70/PHP-Jenkins-Breakfast-Box

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP-Jenkins-Breakfast-Box

I'm sitting in my pajamas an hour before work starts. All I want is a Jenkins server for my PHP project to analyze the kerfluffle out of is fart box. Screw wasting time figuring out Chef or Anisble. I just want to figure out what the C.R.A.P. is going on with my PHP: HP project. All I want is to input some commands, install my PHP: HP: HP jenkins box while eating some delicious PHPancakes.

alt text

Table Of Contents:

The Requirements

You thought that was a Download And Analyze (DAA) project, but you are mistaken! To run the PHP: HP: HP: HP-Jenkins-Breakfast-Box we need to install dependencies:

  • VirtualBox
    • Make sure to download the latest version, even if you already installed VirtualBox before.
    • As of writing this my version (AOWTMV) is 5.1.14
  • Vagrant
    • AOWTMV is 1.8.6
  • A Computer

The Process

To run the breakfast box go to your terminal, clone the repository, and run vagrant up:

$ git clone https://github.com/fufu70/jenkins-php-box
$ vagrant up

After the PHP: HP: HP: HP: HP-Jenkins-Breakfast-Box "up"s it will gives instructions on what to do:

You Installed the PHP-Jenkins-Breakfast-Box ... YAY! Run 'vagrant ssh', and 'sudo bash ~/install-jenkins/install.sh'

Dont tell me what to do Vagrant! Im a well adgusted programmer! I know, i'll:

$ vagrant ssh
$ sudo bash ~/install-jenkins/install.sh

Yea! I don't need no program telling me what to do ...

Ok! Go to your browser at http://192.168.205.20:8080 to setup your PHP-Jenkins-Breakfast-Box

What's this! More instructions!

After you make your own goddam decisions you adult you'll see a screen that requests you Unlock Jenkins alt text

Run:

$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Copy and paste the password shown after the command is run.

You then come up to a screen that requests you to Customize Jenkins, choose the highlighted "Install suggested plugins" option alt text

Afterwards it will install a list of generalized selection of plugins alt text

Once the plugins are installed create the first admin user. Don't forget the username and password, we'll need it later. alt text

JENKINS IS INSTALLED!!!~ alt text

Now we go back to our handy dandy terminal to run more commands

U should still be in the vagrant machines shell, if not run:

$ vagrant ssh

OK! So all we gotta do is run 3 more commands and we should be done with shell. These commands go to install some more php specific plugins, local php tools that the plugins interface with, and create a job to connect with these plugins.

The first command will be php tools.

$ sudo bash ~/install-jenkins/php-tools.sh

Then install the plugins for the php tools. You will need a username and password for jenkins as it connects to the PHP-Jenkins-Breakfast-Box through a jenkins-cli.jar.

$ sudo bash ~/install-jenkins/plugins.sh

Once the plugins have been installed we want to actually create a job! Don't forget that username and password.

$ sudo bash ~/install-jenkins/integration.sh

When running this command you'll be given an option to input a personal repository. If N is selected then the repository URL can be changed from the config section of the jenkins job at http://192.168.205.20:8080/job/php-breakfast-box-job/configure. The second option below is the Source Code Management config, here you can set a repository url and credentials:

alt text

Your done now, you should be anyways, When you go back to your running jenkins instance you should see your job just hanging out, php-breakfast-box-job.

Ok, your work alarm has rung! Get back to your Hacking you filthy developer!

Troubleshooting

Content Security Policy Issues

Okay my fellow scrubs! You finally got your first job to run, you head over to your Clover Code Coverage html reports (CCCHR) at http://192.168.205.20:8080/job/php-breakfast-box-job/cloverphp/. Whats this!

alt text

What are all these console errors!

alt text

This is a direct issue with the Content Security Policy issue. Were going to run a script inside of Jenkins internal console. Go to http://192.168.205.20:8080/script and run:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

Inside of the script console.

alt text

After running the script go back to the CCCHR page at http://192.168.205.20:8080/job/php-breakfast-box-job/cloverphp/, hard refresh the page to clear your current cache, and view the splendor of no Content Security!

alt text

Markup Formating in the Job Description

Cruising to your job you see a odd bug out of the corner of your eye!

alt text

Thats not suppose to be like that but it is be like that ...

The problems of global configuration policies! Simply go to http://192.168.205.20:8080/configureSecurity/ to set the Markup Formatter value to be safe html

alt text

After you click save you can now view those pretty little pdepend graphs.

alt text

Keep on analyzing that code!

The Tools

The PHP Jenkins Breakfast Box comes with several different tools for code analysis, 7 to be exact.

Rummages through your code to let you know of code that does not follow your linting rules.

Do you like CRAP? Do you like Code Coverage? Do you enjoy the relaxing sounds of your test cases failing? Look no further, PHPUnit has it all. This little code analysis tool will point out method that have a cyclomatic complexity higher than 30 (higher than 100 is troublesome), show you your total code coverage for a class (the clover coverage section). and let you know how many test cases have passed or failed.

Do you like generalized information??? Well? Do you? Well PHPLOC will do just that, let you know the total amount of in your codebase, meaning:

  • Lines of Code (LOC)
  • Comment Lines of Code (CLOC)
  • Non-Comment Lines of Code (NCLOC)
  • Logical Lines of Code (LLOC)
  • Average Complexity per LLOC
  • Average Complexity per Class
  • Namespaces
  • Interfaces
  • Traits
  • Classes
  • Methods
  • Functions
  • Constants
  • ...

Coupled with the phploc plugin in Jenkins you can see your codebase grow with each commit and connect it with growing or shrinking Cyclomatic Complexity.

When you first look at it you ask yourself ... WTF am i looking at! You have some weird graph that has instability on the vertical side, and abstraction on the other in conjunction with a pyramid that tells you the Inheritance, Coupling, and Size / Complexity of your codebase.

Operates similarly to the PMD project for Java. To copy directly from PHPMD's website, it simply looks for:

  • Possible bugs
  • Suboptimal code
  • Overcomplicated expressions
  • Unused parameters, methods, properties

The PHP Copy Paste Detector. Operates similarly to PMD's CPD.

PHPDox, written by Arne Blankerts, is used to create PHP documentation on the fly from currently documented code.

General Information

A basic jenkins environment for PHP codebases strictly for ubuntu-14.04. Its not fully automatic but is an aid in starting up the project simply using shell scripts as a guide.

The default repository for the job is the yii-deadbody-php project. It is a good aid in testing the PHP-Jenkins-Breakfast-Box.

TLDC (To Long Didn't Code)

To quickly setup an instance checkout the Vagrantfile for the result of the process: PHP-Jenkins-Vagrant-File

Thanks to:

Sebastian Bergmann for creating the Template for Jenkins Jobs for PHP Projects

Papa Johns for making it all happen

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages