Skip to content

Instantly share code, notes, and snippets.

@smartgammadev
Last active February 9, 2022 10:47
Show Gist options
  • Save smartgammadev/790df34fbc52c481c03df8d99f8ae37d to your computer and use it in GitHub Desktop.
Save smartgammadev/790df34fbc52c481c03df8d99f8ae37d to your computer and use it in GitHub Desktop.
Smart Gamma CI script that allows to collect all failed Behat tests executed in multithreading mode at Jenkins console output log and pass it to behat for restart
#!/usr/bin/env php
<?php
$logFilename = getenv('JENKINS_HOME') . '/'. str_replace(getenv('JENKINS_URL'), '', getenv('JOB_URL'));
$logFilename = str_replace('/job/', '/jobs/', $logFilename) . 'builds/'. getenv('BUILD_NUMBER') . '/log';
$text = file_get_contents($logFilename);
preg_match_all('/Failed scenarios:(.*?)\d+\sscenario/is', $text, $m);
list($original, $threads) = $m;
$features = [];
foreach($threads as $thread) {
$features = array_filter(explode("\n",$thread));
foreach($features as $feature) {
echo trim($feature) . "\n";
}
}
?>
@mastervishant
Copy link

where we have to save this file. Can u plz tell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment