Added notification on job fail
All checks were successful
Push image to registry / build-image (push) Successful in 5m20s
All checks were successful
Push image to registry / build-image (push) Successful in 5m20s
This commit is contained in:
@ -5,6 +5,8 @@ namespace App\Browser;
|
||||
use App\Models\Job;
|
||||
use App\Models\JobArtifact;
|
||||
use App\Models\JobRun;
|
||||
use App\Notification\Notifications\JobErrorNotification;
|
||||
use App\Notification\Providers\AllNotification;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||
@ -57,6 +59,7 @@ abstract class BrowserJob implements ShouldQueue
|
||||
}
|
||||
catch (Throwable $e) {
|
||||
$browser->screenshot("failure-{$this->jobId}");
|
||||
AllNotification::send(new JobErrorNotification($this->jobId, $e->getMessage()));
|
||||
dump($e);
|
||||
throw $e;
|
||||
} finally {
|
||||
|
27
app/Browser/JobErrorScreenshot.php
Normal file
27
app/Browser/JobErrorScreenshot.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use function rtrim;
|
||||
|
||||
|
||||
class JobErrorScreenshot {
|
||||
public const IMG_FILE_NAME = "failure-";
|
||||
|
||||
private static function getFileName(int $jobId): string {
|
||||
return static::IMG_FILE_NAME . $jobId . ".png";
|
||||
}
|
||||
|
||||
public static function getImgFileAbsolutePath(int $jobId): string {
|
||||
return rtrim(Browser::$storeScreenshotsAt, '/') . "/" . static::getFileName($jobId);
|
||||
}
|
||||
|
||||
public static function getImgFileProjectPath(int $jobId): string {
|
||||
return app_path("Browser/screenshots/" . static::getFileName($jobId));
|
||||
}
|
||||
|
||||
public static function getImgFileExternalPath(int $jobId): string {
|
||||
return "screenshots/" . static::getFileName($jobId);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user