I am using H开发者_运维百科udson for CI and, inside it, Phing for automated testing. When I specify a phpunit task in build.xml, the test suite is run. My question is: How does this happen? Hudson is running inside JVM while PHP requires a PHP container.
It seems as if PHP is installed as CLI standalone application. If this is the case then I can somehow run tests written in phpRack which is not supported by Phing. Right? But How?
I have been searching on this but it seems as if phpRack is not well supported by others.
Ant uses an <exec>
task to run most of the external tools like PHPUnit. If PhpRack has a CLI mode you can use it the same way. However, you'll need a post processor for the output to determine pass or fail.
Edit: Oops, how did I miss Phing? LOL. The same principle applies as the other answers described.
Hudson/Jenkins doesn't call PHP 'directly' but with the help of your build file. Your phing.xml or ant.xml or whatever you use.
And that file just fires normal system calls (in php you would do system("/usr/bin/php file.php");
or something similar.
So if you and to call a command line tool it just calls it like that. If you send out a http-request (as the phpRack examples show) you need to make sure that you have a working web server installed and the url can be accessed just as a browser would access it.
As mentioned in the previous answers you can run anything in Phing as long as you can run it from the shell. What you're looking for in the job configuration in Hudson/Jenkins is:
Add Build Step -> Execute Shell -> Command.
In there just put something like /usr/bin/php /path/to/your/script.php
and it will be executed.
NB There is an example of integrating Phing phpRack, so you could maybe actually use that: https://github.com/tpc2/phprack/wiki/Phing
精彩评论