My jenkins install is working properly just that the phpunit+coverage on my code takes 5 minutes finish - because of too many files.
For me, it's too much wait for just knowing if my last commit broke the build or not.
Is there a way I can run a special build (or scheduled) when jenkins is idle and while only in that build it will create phpunit code coverage reports?
I could run phpunit -c with-coverage.xml
in cron but that is isolated from jenkins, it does not refresh jenkin's job home page.
This is a common general problem: you want a first-tier build to quickly tell you if you've broken the application and a second-tier build to perform deeper analysis. Things that take more time in this latter build include
You can achieve this using two separate Jenkins projects--each executing an appropriate Ant task--where the second build is dependent on the first build's success. I believe you can even have the first-tier build pass artifacts (e.g. junit.xml) to the second-tier build, but I haven't had the time to experiment with this yet.
Unfortunately, this is a half-answer. I know you can do it, but I haven't done it myself, nor can I tell you step-by-step how to do it. Hopefully this gives you enough pointers to get you started.
If you are using ant
to orchestrate your build maybe you don't even need a two-tier build but you can use tell Jenkins/Ant to stop when your tests fail as you usually don't really care about metrics when you break the build.
What I tend to use is:
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
</target>
as on of the first build targets. It will try to generate code-coverage so the phpunit run takes a littler longer but you don't have to spend time to generate all the metrics.
If you want it really fast:
You can tell Jenkins to have a "post build action" that starts another build when your 'run tests' build succeeded. You can even set it up to wait half an hour or so to start the "Metrics" build just in case you do 3-4 commits and don't want the metric build to start immediately after the first one worked out
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With