add notification to drone pipeline

This commit is contained in:
Robert Kaussow 2019-10-08 15:55:24 +02:00
parent 87390a1be5
commit b75546078e
3 changed files with 68 additions and 5 deletions

View File

@ -155,9 +155,39 @@ local PipelineBuild = {
}, },
}; };
local PipelineNotifications = {
kind: "pipeline",
name: "notifications",
platform: {
os: "linux",
arch: "amd64",
},
steps: [
{
name: "matrix",
image: "plugins/matrix",
settings: {
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
roomid: { "from_secret": "matrix_roomid" },
homeserver: { "from_secret": "matrix_homeserver" },
username: { "from_secret": "matrix_username" },
password: { "from_secret": "matrix_password" },
},
},
],
depends_on: [
"build",
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**"],
status: [ "success", "failure" ],
},
};
[ [
PipelineLint, PipelineLint,
PipelineTest, PipelineTest,
PipelineSecurity, PipelineSecurity,
PipelineBuild, PipelineBuild,
PipelineNotifications,
] ]

View File

@ -177,8 +177,41 @@ trigger:
depends_on: depends_on:
- security - security
---
kind: pipeline
name: notifications
platform:
os: linux
arch: amd64
steps:
- name: matrix
image: plugins/matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
username:
from_secret: matrix_username
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
status:
- success
- failure
depends_on:
- build
--- ---
kind: signature kind: signature
hmac: 7b7b9ad0e0945e50acc6c70bd430574f6ab8df62013692e12cbdcf5018baafe9 hmac: 602f1e2058d0b5d15da827d7893c2f111bb161741bfd7ea60cc2b882e1a54ea2
... ...

View File

@ -17,6 +17,10 @@ CONSOLE_FORMAT = "{}[%(levelname)s]{} %(message)s"
JSON_FORMAT = "(asctime) (levelname) (message)" JSON_FORMAT = "(asctime) (levelname) (message)"
def to_bool(string):
return bool(strtobool(str(string)))
def _should_do_markup(): def _should_do_markup():
py_colors = os.environ.get("PY_COLORS", None) py_colors = os.environ.get("PY_COLORS", None)
if py_colors is not None: if py_colors is not None:
@ -215,7 +219,3 @@ class FileUtils:
to_bool(choice) to_bool(choice)
except (KeyboardInterrupt, ValueError) as e: except (KeyboardInterrupt, ValueError) as e:
raise ansibledoctor.Exception.InputError("Error while reading input", e) raise ansibledoctor.Exception.InputError("Error while reading input", e)
def to_bool(string):
return bool(strtobool(str(string)))