From 0ca566e5e2f0b4e03593bed3060fbbae318405dd Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sat, 3 Feb 2024 00:18:09 +0100 Subject: [PATCH 1/3] add commit.prerelease (CI_COMMIT_PRERELEASE) --- DOCS.md | 1 + bin/console | 1 + 2 files changed, 2 insertions(+) diff --git a/DOCS.md b/DOCS.md index c099d83..c031951 100644 --- a/DOCS.md +++ b/DOCS.md @@ -76,6 +76,7 @@ See the [Twig documentation](https://twig.symfony.com/doc/3.x/). | `commit.author` | `CI_COMMIT_AUTHOR` | | `commit.author_email` | `CI_COMMIT_AUTHOR_EMAIL` | | `commit.author_avatar` | `CI_COMMIT_AUTHOR_AVATAR` | +| `commit.prerelease` | `CI_COMMIT_PRERELEASE` | | `prev_commit.sha` | `CI_PREV_COMMIT_SHA` | | `prev_commit.ref` | `CI_PREV_COMMIT_REF` | | `prev_commit.branch` | `CI_PREV_COMMIT_BRANCH` | diff --git a/bin/console b/bin/console index a4da810..1ae982e 100755 --- a/bin/console +++ b/bin/console @@ -32,6 +32,7 @@ $build = EnvVarLoader::buildArray([ 'author' => 'CI_COMMIT_AUTHOR', 'author_email' => 'CI_COMMIT_AUTHOR_EMAIL', 'author_avatar' => 'CI_COMMIT_AUTHOR_AVATAR', + 'prerelease' => 'CI_COMMIT_PRERELEASE', ], 'prev_commit' => [ 'sha' => 'CI_PREV_COMMIT_SHA', From c86fa454d526e1dd7d052148eb0c0f233031d6b5 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 19 Feb 2024 14:24:42 +0100 Subject: [PATCH 2/3] add setting "debug" --- DOCS.md | 1 + bin/console | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/DOCS.md b/DOCS.md index c031951..bec9431 100644 --- a/DOCS.md +++ b/DOCS.md @@ -21,6 +21,7 @@ url: https://gitnet.fr/deblan/woodpecker-email | content.subject | no | `string` | Define the email subject template | | | content.body | no | `string` | Define the email body template | | | attachments | no | `string` or `list` | List of files to attach | YAML list or comma separated list | +| debug | no | `boolean` | Debug mode (email are sent!) | | diff --git a/bin/console b/bin/console index 1ae982e..a9848e9 100755 --- a/bin/console +++ b/bin/console @@ -89,8 +89,10 @@ $config = EnvVarLoader::buildArray([ 'attachments' => 'PLUGIN_ATTACHMENTS', 'evaluate' => 'PLUGIN_EVALUATE', 'content' => 'PLUGIN_CONTENT', + 'is_debug' => 'PLUGIN_DEBUG', ], [ 'PLUGIN_RECIPIENTS_ONLY' => true, + 'PLUGIN_DEBUG' => false, ]); function writeln(...$values) @@ -110,6 +112,18 @@ function handleError($section, Exception $e) exit(1); } +if ($config['is_debug']) { + writeln( + 'Debug', + '=====', + 'Config', + json_encode($config, JSON_PRETTY_PRINT), + 'Environment', + json_encode($_SERVER, JSON_PRETTY_PRINT), + '=====' + ); +} + $twig = (new TwigFactory())->create(); $emailFactory = new EmailFactory($twig, $config, $build); $evaluation = new Evaluation($twig); From 4f18199467e95456925483e102bbf8b1c9f8ef00 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 3 Jun 2024 12:16:49 +0200 Subject: [PATCH 3/3] allow to debug the build --- bin/console | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/console b/bin/console index 8930d0f..7d9e524 100755 --- a/bin/console +++ b/bin/console @@ -127,7 +127,11 @@ if ($config['is_debug']) { writeln( 'Debug', '=====', - json_encode(['config' => $config, 'environment' => $_SERVER], JSON_PRETTY_PRINT), + json_encode([ + 'config' => $config, + 'environment' => $_SERVER, + 'build' => $build, + ], JSON_PRETTY_PRINT), '=====', ); }