├── .bashrc ├── Dockerfile ├── README.md └── jobs └── php-template └── config.xml /.bashrc: -------------------------------------------------------------------------------- 1 | PATH=$PATH:/home/jenkins/vendor/bin -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Official images are cool. 2 | FROM jenkins 3 | MAINTAINER Ignacio Tolstoy 4 | 5 | # Jenkins is using jenkins user, we need root to install things. 6 | USER root 7 | 8 | RUN mkdir -p /tmp/WEB-INF/plugins 9 | 10 | # Install required jenkins plugins. 11 | RUN curl -L https://updates.jenkins-ci.org/latest/checkstyle.hpi -o /tmp/WEB-INF/plugins/checkstyle.hpi 12 | RUN curl -L https://updates.jenkins-ci.org/latest/cloverphp.hpi -o /tmp/WEB-INF/plugins/cloverphp.hpi 13 | RUN curl -L https://updates.jenkins-ci.org/latest/crap4j.hpi -o /tmp/WEB-INF/plugins/crap4j.hpi 14 | RUN curl -L https://updates.jenkins-ci.org/latest/dry.hpi -o /tmp/WEB-INF/plugins/dry.hpi 15 | RUN curl -L https://updates.jenkins-ci.org/latest/htmlpublisher.hpi -o /tmp/WEB-INF/plugins/htmlpublisher.hpi 16 | RUN curl -L https://updates.jenkins-ci.org/latest/jdepend.hpi -o /tmp/WEB-INF/plugins/jdepend.hpi 17 | RUN curl -L https://updates.jenkins-ci.org/latest/plot.hpi -o /tmp/WEB-INF/plugins/plot.hpi 18 | RUN curl -L https://updates.jenkins-ci.org/latest/pmd.hpi -o /tmp/WEB-INF/plugins/pmd.hpi 19 | RUN curl -L https://updates.jenkins-ci.org/latest/violations.hpi -o /tmp/WEB-INF/plugins/violations.hpi 20 | RUN curl -L https://updates.jenkins-ci.org/latest/xunit.hpi -o /tmp/WEB-INF/plugins/xunit.hpi 21 | 22 | # Install Docker plugin for docker deploy. 23 | RUN curl -L https://updates.jenkins-ci.org/latest/docker-build-publish.hpi -o /tmp/WEB-INF/plugins/docker-build-publish.hpi 24 | 25 | # Add all to the war file. 26 | RUN cd /tmp; \ 27 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/checkstyle.hpi && \ 28 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/cloverphp.hpi && \ 29 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/crap4j.hpi && \ 30 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/dry.hpi && \ 31 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/htmlpublisher.hpi && \ 32 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/jdepend.hpi && \ 33 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/plot.hpi && \ 34 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/pmd.hpi && \ 35 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/violations.hpi && \ 36 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/xunit.hpi 37 | zip --grow /usr/share/jenkins/jenkins.war WEB-INF/plugins/docker-build-publish.hpi 38 | 39 | # Install php packages. 40 | RUN apt-get update 41 | RUN apt-get -y -f install php5-cli php5-dev php5-curl curl php-pear ant 42 | 43 | # Install docker 44 | RUN apt-get -y -f install docker.io 45 | 46 | # Create a jenkins "HOME" for composer files. 47 | RUN mkdir /home/jenkins 48 | RUN chown jenkins:jenkins /home/jenkins 49 | 50 | USER jenkins 51 | 52 | #### This don't work as $JENKINS_HOME is a volume #### 53 | # Install php template. 54 | #RUN mkdir "$JENKINS_HOME/jobs/php-template" 55 | #RUN curl -L https://raw.github.com/sebastianbergmann/php-jenkins-template/master/config.xml -o "$JENKINS_HOME/jobs/php-template/config.xml" 56 | #### sad panda is sad #### 57 | 58 | 59 | # Install composer, yes we can't install it in $JENKINS_HOME :( 60 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/home/jenkins 61 | 62 | # Install required php tools. 63 | RUN /home/jenkins/composer.phar --working-dir="/home/jenkins" -n require phing/phing:2.6.1 notfloran/phing-composer-security-checker:~1.0 \ 64 | phploc/phploc:* phpunit/phpunit:~4.1 pdepend/pdepend:~1.1 phpmd/phpmd:~1.4 sebastian/phpcpd:* \ 65 | squizlabs/php_codesniffer:* mayflower/php-codebrowser:~1.1 66 | #RUN echo "export PATH=$PATH:/home/jenkins/.composer/vendor/bin" >> $JENKINS_HOME/.bashrc # Keep dreaming! 67 | 68 | USER root 69 | RUN apt-get clean -y 70 | 71 | # Go back to jenkins user. 72 | USER jenkins 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Jenkins-PHP Docker 2 | ========= 3 | 4 | Here is another Jenkins-php template docker. 5 | With the difference that **this one works**. 6 | 7 | Is based on the Jenkins official docker image. 8 | 9 | 10 | Installing 11 | ---- 12 | 13 | Saddly you just can't run the docker image and start working. You need to clone this repo. This is because the Jenkins image sets a volume for the jenkins home folder. And you will need to add the php template to that folder. 14 | 15 | - Clone this [repo] where you want. Like: /var/docker/jenkins-php-docker 16 | - Or you can just copy the files from the [repo] 17 | - - Give `rwx` rights for the `jenkins` user in that folder 18 | - Run the image `docker run -d -P -v /var/docker/jenkins-php-docker:/var/jenkins_home:rw naxhh/jenkins-php-docker` 19 | 20 | Docker exposes the port `8080` so just go to `http://:8080` 21 | 22 | Configure a project 23 | ----------- 24 | 25 | Now you have a Jenkins working. 26 | So you just need to configure your project. You can Follow the instructions in [jenkins-php] guide. 27 | 28 | For a quick test you can set up a project for the [Money] project 29 | 30 | - Create a new work 31 | - Configure it as git and add the [Money] project clone url 32 | - You can save the work without any modification 33 | - Build the project and see the results. 34 | 35 | 36 | Common problems or errors 37 | --- 38 | - Remember to add privileges for the `jenkins` user. 39 | - Job description by default have two images, you need to configure html rendering in the security options 40 | 41 | 42 | [jenkins-php]:http://jenkins-php.org/integration.html 43 | [Money]:https://github.com/sebastianbergmann/money 44 | [repo]:https://github.com/naxhh/jenkins-php-docker.git -------------------------------------------------------------------------------- /jobs/php-template/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <img type="image/svg+xml" height="300" src="ws/build/pdepend/overview-pyramid.svg" width="500"></img> 5 | <img type="image/svg+xml" height="300" src="ws/build/pdepend/dependencies.svg" width="500"></img> 6 | false 7 | 8 | 9 | true 10 | true 11 | false 12 | false 13 | 14 | false 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | low 25 | [CHECKSTYLE] 26 | 27 | true 28 | false 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | false 48 | build/logs/checkstyle.xml 49 | 50 | 51 | 52 | 53 | low 54 | [PMD] 55 | 56 | true 57 | false 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | false 77 | build/logs/pmd.xml 78 | 79 | 80 | 81 | 82 | low 83 | [DRY] 84 | 85 | true 86 | false 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | false 106 | build/logs/pmd-cpd.xml 107 | 50 108 | 25 109 | 110 | 111 | 112 | 113 | A - Lines of code 114 | Lines of Code 115 | 116 | 117 | build/logs/phploc.csv 118 | 133 | 134 | phploc 135 | 100 136 | 123.csv 137 | 0 138 | 139 | false 140 | 141 | 142 | B - Structures Containers 143 | Count 144 | 145 | 146 | build/logs/phploc.csv 147 | 159 | 160 | phploc 161 | 100 162 | 1107599928.csv 163 | 0 164 | 165 | false 166 | 167 | 168 | C - Average Length 169 | Average Lines of Code 170 | 171 | 172 | build/logs/phploc.csv 173 | 187 | 188 | phploc 189 | 100 190 | 523405415.csv 191 | 0 192 | 193 | false 194 | 195 | 196 | D - Relative Cyclomatic Complexity 197 | Cyclomatic Complexity by Structure 198 | 199 | 200 | build/logs/phploc.csv 201 | 214 | 215 | phploc 216 | 100 217 | 186376189.csv 218 | 0 219 | 220 | false 221 | 222 | 223 | E - Types of Classes 224 | Count 225 | 226 | 227 | build/logs/phploc.csv 228 | 240 | 241 | phploc 242 | 100 243 | 594356163.csv 244 | 0 245 | 246 | false 247 | 248 | 249 | F - Types of Methods 250 | Count 251 | 252 | 253 | build/logs/phploc.csv 254 | 270 | 271 | phploc 272 | 100 273 | 1019987862.csv 274 | 0 275 | 276 | false 277 | 278 | 279 | G - Types of Constants 280 | Count 281 | 282 | 283 | build/logs/phploc.csv 284 | 296 | 297 | phploc 298 | 100 299 | 217648577.csv 300 | 0 301 | 302 | false 303 | 304 | 305 | I - Testing 306 | Count 307 | 308 | 309 | build/logs/phploc.csv 310 | 321 | 322 | phploc 323 | 100 324 | 174807245.csv 325 | 0 326 | 327 | false 328 | 329 | 330 | AB - Code Structure by Logical Lines of Code 331 | Logical Lines of Code 332 | 333 | 334 | build/logs/phploc.csv 335 | 350 | 351 | phploc 352 | 100 353 | 946905520.csv 354 | 0 355 | 356 | false 357 | 358 | 359 | H - Types of Functions 360 | Count 361 | 362 | 363 | build/logs/phploc.csv 364 | 376 | 377 | phploc 378 | 100 379 | 1174623854.csv 380 | 0 381 | 382 | false 383 | 384 | 385 | BB - Structure Objects 386 | Count 387 | 388 | 389 | build/logs/phploc.csv 390 | 407 | 408 | phploc 409 | 100 410 | 1234245913.csv 411 | 0 412 | 413 | false 414 | 415 | 416 | 417 | 418 | true 419 | build/coverage 420 | build/logs/clover.xml 421 | false 422 | 423 | 70 424 | 80 425 | 426 | 427 | 428 | 429 | 430 | build/logs/crap4j.xml 431 | 432 | 433 | 434 | 435 | 436 | API Documentation 437 | build/api 438 | index.html 439 | true 440 | htmlpublisher-wrapper.html 441 | 442 | 443 | 444 | 445 | 446 | 447 | build/logs/junit.xml 448 | true 449 | true 450 | true 451 | 452 | 453 | 454 | 455 | 0 456 | 0 457 | 0 458 | 0 459 | 460 | 461 | 0 462 | 0 463 | 0 464 | 0 465 | 466 | 467 | 1 468 | 469 | 470 | build/logs/jdepend.xml 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | checkstyle 481 | 482 | checkstyle 483 | 10 484 | 999 485 | 999 486 | false 487 | build/logs/checkstyle.xml 488 | 489 | 490 | 491 | codenarc 492 | 493 | codenarc 494 | 10 495 | 999 496 | 999 497 | false 498 | 499 | 500 | 501 | 502 | cpd 503 | 504 | cpd 505 | 10 506 | 999 507 | 999 508 | false 509 | build/logs/pmd-cpd.xml 510 | 511 | 512 | 513 | cpplint 514 | 515 | cpplint 516 | 10 517 | 999 518 | 999 519 | false 520 | 521 | 522 | 523 | 524 | csslint 525 | 526 | csslint 527 | 10 528 | 999 529 | 999 530 | false 531 | 532 | 533 | 534 | 535 | findbugs 536 | 537 | findbugs 538 | 10 539 | 999 540 | 999 541 | false 542 | 543 | 544 | 545 | 546 | fxcop 547 | 548 | fxcop 549 | 10 550 | 999 551 | 999 552 | false 553 | 554 | 555 | 556 | 557 | gendarme 558 | 559 | gendarme 560 | 10 561 | 999 562 | 999 563 | false 564 | 565 | 566 | 567 | 568 | jcreport 569 | 570 | jcreport 571 | 10 572 | 999 573 | 999 574 | false 575 | 576 | 577 | 578 | 579 | jslint 580 | 581 | jslint 582 | 10 583 | 999 584 | 999 585 | false 586 | 587 | 588 | 589 | 590 | pep8 591 | 592 | pep8 593 | 10 594 | 999 595 | 999 596 | false 597 | 598 | 599 | 600 | 601 | pmd 602 | 603 | pmd 604 | 10 605 | 999 606 | 999 607 | false 608 | build/logs/pmd.xml 609 | 610 | 611 | 612 | pylint 613 | 614 | pylint 615 | 10 616 | 999 617 | 999 618 | false 619 | 620 | 621 | 622 | 623 | simian 624 | 625 | simian 626 | 10 627 | 999 628 | 999 629 | false 630 | 631 | 632 | 633 | 634 | stylecop 635 | 636 | stylecop 637 | 10 638 | 999 639 | 999 640 | false 641 | 642 | 643 | 644 | 645 | 100 646 | 647 | 648 | default 649 | 650 | 651 | 652 | 653 | --------------------------------------------------------------------------------