Closed AaronJan closed 9 years ago
I have successfully repeated the problem, got stuck at the same place at 100%. This one was corrected when I changed src to app dir in phpunit.xml's whitelist block.
However I will give all the steps I just made to make a successful build in Jenkins with a Laravel project. Check the final result here: http://jenkins.iliyan-trifonov.com/job/LaravelTestEmptyProject/ You will see I've made a couple of tests while looking at the errors in the console output to make the configuration compatible with this project.
I've used my Gitlab and put the files here: http://gitlab.iliyan-trifonov.com/laravel/test-empty-laravel-project/tree/master
There's one requirement to the Jenkins Docker image that I corrected in the new version/tag: 1.0.3: php5-mcrypt was needed.
First check if all the builds finished here https://registry.hub.docker.com/u/iliyan/jenkins-ci-php/builds_history/72106/
and then fetch the new image with: sudo docker pull iliyan/jenkins-ci-php:1.0.3
.
Remove the current Jenkins container: sudo docker stop jenkins && sudo docker rm jenkins
.
Run the new one: sudo docker run -d --name jenkins -p 127.0.0.1:8080:8080 iliyan/jenkins-ci-php:1.0.3
.
You should be ready now to add your project with the configuration changes explained below.
These are the steps:
Local:
mkdir test-laravel-empty-project
cd test-laravel-empty-project
composer create-project laravel/laravel~4 .
Create ./build.xml from your code here
Add vendors
configuration in build.xml
(check my test repo on Gitlab)
Add build/
dir with phpcs.xml
, phpdox.xml
, phpmd.xml
and phpunit.xml
(check my test repo on Gitlab)
I will be using phpunit config from build/phpunit.xml
.
Change src
dir to app
in whitelist
block in build/phpunit.xml
and in build/phpdox.xml
(check my test repo on Gitlab)
Change logs/coverage
to coverage/xml
in build/phpunit.xml
(check my test repo on Gitlab)
git init
git remote add origin ssh://git@gitlab.iliyan-trifonov.com:52222/laravel/test-empty-laravel-project.git
git add .
git commit -m "initial commit"
git push -u origin master
Jenkins:
New project: LaravelTestEmptyProject - copy from php-template
Uncheck Freeze build
Check Git VCS
I've set repo url to: http://gitlab.iliyan-trifonov.com/laravel/test-empty-laravel-project.git
Change index.xhtml
to index.html
in the Publish HTML reports
section. This will fix the missing Api documentation link in the Jenkins' project dashboard.
Save
Build Now
Mcrypt PHP extension required.
If you are not on the 1.0.3 image, install the extension manually:
docker exec -ti jenkins bash
apt-get update && apt-get install php5-mcrypt
exit
This will add the extension to the container which you may commit to your personal images. Otherwise fetch the updated 1.0.3 image.
Click Build Now in Jenkins and it should succeed.
I also got used to letting the build.xml update composer and all its required tools as well as the vendors dir which makes it independent from the current tools' versions inside the image. For this variant check my other build here: https://github.com/iliyan-trifonov/mvc-behat-phpunit/blob/master/build.xml
Thank you for your very detailed reply! Really helped me a lot! :smile:
I ran into the missing mcrypt
problem too, but your image setting timezone to Europe/Sofia
, so I just builded an new image base on yours to solving this two things.
I'm building a PHP
development system all around Docker
, thanks for your helping, now I can get the whole thing working.
I think your configure files could help a lot people like me, maybe you can find a way to use them.
Thank you again!
I am happy to help! :smile:
You also helped me by letting me think about how to test a Laravel app and with the time zone. :+1:
I am planning to introduce environment vars while running the container to change the timezone on the fly but I guess I was waiting for it to be required :) I will make it next time I update the project.
I'm using this image for a couple of days and had one problem that I really don't know why:
Jenkins always get stuck in PHPUnit "Generating code coverage report in PHPUnit XML format..." process.
On my real machine only take less than 2 minutes, but in docker it's taking forever, and cpu usage is 100%. The project is an official Laravel 4.3 example, created by
composer create-project laravel/laravel --prefer-dist
, and thebuild.xml
,phpunit.xml
is like this:build.xml
phpunit.xml
Is something wrong in my xml files?