简体   繁体   中英

phing : sending the full log by email?

I'm using phing for some automatic-building process on a project, and was wondering : how can I get the full log by email ?


When I launch phing by the command-line, the building-log is displayed ; I would like it :

  • sent by e-mail,
  • to several recipients,
  • whether the build succeeded or failed
  • ideally : with a subject for the mail telling if the build succeeded or failed
  • ideally : some kind of HTML mail, with formatting, colors, ... would be nice

I've though about piping the ouput of phing to the mail command, but I would like a solution that work on both Linux and Windows, and doesn't require the installation of any additional software...

Does anyone have an idea ?


As a sidenote : I've thought about adding some kind of "report" target, launched at the end of the build, but :

  • It is launched only if all previous targets did not fail
  • I don't see how to get the full-log in it

Great idea; just added a ticket to implement this @ http://phing.info/trac/ticket/539

I guess you could write a custom Phing build listener / logger handling your described use case. Take a look at this excellent blog post by Philip Norton, to get you going.

This is something you can do without the installation of additional software assuming you are able to write a script for a linux server you have access to.

Have a php script use the exec() or system() command to obtain the full log. Send this as http post data using curl to your remote script on the linux server you have access to.

On the server you have access to write a script to accept the http post variable and mail the content to your email address(es). And you might think "Oh no, I have open access to people emailing me!" If they know your address or you have a web contact form... same deal. So that is a solution ;) If security's a concern send it via https.

We use sth. like this wrapped in a php script.

exec('phing' . $target . ' -f ' . $buildfile . ' | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"', $out); //remove bash color
$info = implode("\n", $out);
$subj = sprintf('Deployed %s', $catalogInfo['name']);
mail($data->email, $subj, $info); 

Works fine.

你看过PEAR邮件包吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM