Automatic job (phpunit with code coverage) when jenkins is idle?

My jenkins install works correctly, just phpunit + covering my code takes 5 minutes - due to too many files.

For me, this is waiting too much, just knowing that my last fixer broke the assembly or not.

Is there a way to start a special assembly (or scheduled) when jenkins is idle, and although only in this assembly will it generate phpunit code coverage reports?

I can run phpunit -c with-coverage.xml in cron, but it is isolated from jenkins, it does not refresh the jenkin work homepage.

+4
source share
2 answers

This is a common general problem: you want the first-level assembly to tell you quickly if you break the application and the second-level structure for deeper analysis. Things that take more time in this latest build include

  • Code coverage
  • Static analysis (duplication and code complexity)
  • API Documentation

You can achieve this by using two separate Jenkins projects - each of which performs the corresponding Ant task, where the second build depends on the success of the first build. I suppose you can even have artifacts to build the first level (e.g. junit.xml) to build the second level, but I have not had time to experiment with this yet.

Unfortunately, this is a semi-answer. I know that you can do it, but I haven’t done it myself, and I can’t tell you step by step how to do it. Hope this gives you enough pointers to get you started.

+5
source

If you use ant to organize your build, you might not even need a two-tier build, but you can use the Jenkins / Ant command to stop your tests from failing, as you are usually uninterested in when breaking a build.

I usually use:

  <target name="phpunit" description="Run unit tests with PHPUnit"> <exec executable="phpunit" failonerror="true"/> </target> 

as for the first purposes of assembly. It will try to generate code coverage, so running phpunit will take less time, but you don’t have to spend time creating all the metrics.


If you want this to be very fast:

You can tell Jenkins that you have a “post-build action” that starts a new build when your run tests build completed successfully. You can even set it up to wait half an hour or so to start building the Metric just in case you are doing 3-4 commits and don't want the metric build to start right after the first one worked

+4
source

Source: https://habr.com/ru/post/1389620/


All Articles