Commit 34a355fe by Arve Knudsen Committed by GitHub

Drone: Add Slack failure notifier (#27920)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 739395ab
...@@ -276,6 +276,17 @@ steps: ...@@ -276,6 +276,17 @@ steps:
environment: environment:
DOCKERIZE_VERSION: 0.6.1 DOCKERIZE_VERSION: 0.6.1
- name: slack
image: plugins/slack
settings:
channel: grafana-ci-failures
template: "Build {{build.number}} failed: {{build.link}}"
webhook:
from_secret: slack_webhook
when:
status:
- failure
- name: trigger-enterprise-downstream - name: trigger-enterprise-downstream
image: grafana/drone-downstream image: grafana/drone-downstream
settings: settings:
...@@ -642,6 +653,17 @@ steps: ...@@ -642,6 +653,17 @@ steps:
environment: environment:
DOCKERIZE_VERSION: 0.6.1 DOCKERIZE_VERSION: 0.6.1
- name: slack
image: plugins/slack
settings:
channel: grafana-ci-failures
template: "Build {{build.number}} failed: {{build.link}}"
webhook:
from_secret: slack_webhook
when:
status:
- failure
- name: publish-packages - name: publish-packages
image: grafana/grafana-ci-deploy:1.2.6 image: grafana/grafana-ci-deploy:1.2.6
commands: commands:
......
...@@ -9,6 +9,7 @@ dockerize_version = '0.6.1' ...@@ -9,6 +9,7 @@ dockerize_version = '0.6.1'
wix_image = 'grafana/ci-wix:0.1.1' wix_image = 'grafana/ci-wix:0.1.1'
def pr_pipelines(edition): def pr_pipelines(edition):
version_mode = 'pr'
services = [ services = [
{ {
'name': 'postgres', 'name': 'postgres',
...@@ -50,16 +51,18 @@ def pr_pipelines(edition): ...@@ -50,16 +51,18 @@ def pr_pipelines(edition):
postgres_integration_tests_step(), postgres_integration_tests_step(),
mysql_integration_tests_step(), mysql_integration_tests_step(),
] ]
windows_steps = get_windows_steps(edition=edition, version_mode='pr') windows_steps = get_windows_steps(edition=edition, version_mode=version_mode)
trigger = { trigger = {
'event': ['pull_request',], 'event': ['pull_request',],
} }
return [ return [
pipeline( pipeline(
name='test-pr', edition=edition, trigger=trigger, services=services, steps=steps name='test-pr', edition=edition, trigger=trigger, services=services, steps=steps,
version_mode=version_mode,
), ),
pipeline( pipeline(
name='windows-pr', edition=edition, trigger=trigger, steps=windows_steps, platform='windows', name='windows-pr', edition=edition, trigger=trigger, steps=windows_steps, platform='windows',
version_mode=version_mode,
), ),
] ]
...@@ -100,6 +103,7 @@ def master_steps(edition, is_downstream=False): ...@@ -100,6 +103,7 @@ def master_steps(edition, is_downstream=False):
return steps, windows_steps, publish_steps return steps, windows_steps, publish_steps
def master_pipelines(edition): def master_pipelines(edition):
version_mode = 'master'
services = [ services = [
{ {
'name': 'postgres', 'name': 'postgres',
...@@ -128,17 +132,18 @@ def master_pipelines(edition): ...@@ -128,17 +132,18 @@ def master_pipelines(edition):
steps, windows_steps, publish_steps = master_steps(edition=edition) steps, windows_steps, publish_steps = master_steps(edition=edition)
pipelines = [ pipelines = [
pipeline( pipeline(
name='build-master', edition=edition, trigger=trigger, services=services, steps=steps name='build-master', edition=edition, trigger=trigger, services=services, steps=steps,
version_mode=version_mode,
), ),
pipeline( pipeline(
name='windows-master', edition=edition, trigger=trigger, steps=windows_steps, platform='windows', name='windows-master', edition=edition, trigger=trigger, steps=windows_steps, platform='windows',
depends_on=['build-master'], depends_on=['build-master'], version_mode=version_mode,
), ),
] ]
if edition != 'enterprise': if edition != 'enterprise':
pipelines.append(pipeline( pipelines.append(pipeline(
name='publish-master', edition=edition, trigger=trigger, steps=publish_steps, name='publish-master', edition=edition, trigger=trigger, steps=publish_steps,
depends_on=['build-master', 'windows-master',], install_deps=False, depends_on=['build-master', 'windows-master',], install_deps=False, version_mode=version_mode,
)) ))
if edition == 'enterprise': if edition == 'enterprise':
# Add downstream enterprise pipelines triggerable from OSS builds # Add downstream enterprise pipelines triggerable from OSS builds
...@@ -148,21 +153,24 @@ def master_pipelines(edition): ...@@ -148,21 +153,24 @@ def master_pipelines(edition):
steps, windows_steps, publish_steps = master_steps(edition=edition, is_downstream=True) steps, windows_steps, publish_steps = master_steps(edition=edition, is_downstream=True)
pipelines.append(pipeline( pipelines.append(pipeline(
name='build-master-downstream', edition=edition, trigger=trigger, services=services, steps=steps, name='build-master-downstream', edition=edition, trigger=trigger, services=services, steps=steps,
is_downstream=True, is_downstream=True, version_mode=version_mode,
)) ))
pipelines.append(pipeline( pipelines.append(pipeline(
name='windows-master-downstream', edition=edition, trigger=trigger, steps=windows_steps, name='windows-master-downstream', edition=edition, trigger=trigger, steps=windows_steps,
platform='windows', depends_on=['build-master-downstream'], is_downstream=True, platform='windows', depends_on=['build-master-downstream'], is_downstream=True, version_mode=version_mode,
)) ))
pipelines.append(pipeline( pipelines.append(pipeline(
name='publish-master-downstream', edition=edition, trigger=trigger, steps=publish_steps, name='publish-master-downstream', edition=edition, trigger=trigger, steps=publish_steps,
depends_on=['build-master-downstream', 'windows-master-downstream'], is_downstream=True, install_deps=False, depends_on=['build-master-downstream', 'windows-master-downstream'], is_downstream=True, install_deps=False,
version_mode=version_mode,
)) ))
return pipelines return pipelines
def pipeline(name, edition, trigger, steps, services=[], platform='linux', depends_on=[], is_downstream=False, def pipeline(
install_deps=True): name, edition, trigger, steps, version_mode, services=[], platform='linux', depends_on=[],
is_downstream=False, install_deps=True,
):
if platform != 'windows': if platform != 'windows':
platform_conf = { platform_conf = {
'os': 'linux', 'os': 'linux',
...@@ -182,7 +190,9 @@ def pipeline(name, edition, trigger, steps, services=[], platform='linux', depen ...@@ -182,7 +190,9 @@ def pipeline(name, edition, trigger, steps, services=[], platform='linux', depen
'name': name, 'name': name,
'trigger': trigger, 'trigger': trigger,
'services': services, 'services': services,
'steps': init_steps(edition, platform, is_downstream=is_downstream, install_deps=install_deps) + steps, 'steps': init_steps(
edition, platform, is_downstream=is_downstream, install_deps=install_deps, version_mode=version_mode,
) + steps,
'depends_on': depends_on, 'depends_on': depends_on,
} }
...@@ -194,7 +204,23 @@ def pipeline(name, edition, trigger, steps, services=[], platform='linux', depen ...@@ -194,7 +204,23 @@ def pipeline(name, edition, trigger, steps, services=[], platform='linux', depen
return pipeline return pipeline
def init_steps(edition, platform, is_downstream=False, install_deps=True): def slack_step(channel):
return {
'name': 'slack',
'image': 'plugins/slack',
'settings': {
'webhook': {
'from_secret': 'slack_webhook',
},
'channel': channel,
'template': 'Build {{build.number}} failed: {{build.link}}',
},
'when': {
'status': ['failure',],
},
}
def init_steps(edition, platform, version_mode, is_downstream=False, install_deps=True):
if platform == 'windows': if platform == 'windows':
return [ return [
{ {
...@@ -228,7 +254,7 @@ def init_steps(edition, platform, is_downstream=False, install_deps=True): ...@@ -228,7 +254,7 @@ def init_steps(edition, platform, is_downstream=False, install_deps=True):
source_commit = ' $${SOURCE_COMMIT}' source_commit = ' $${SOURCE_COMMIT}'
else: else:
source_commit = '' source_commit = ''
return [ steps = [
identify_runner_step, identify_runner_step,
{ {
'name': 'clone', 'name': 'clone',
...@@ -266,8 +292,11 @@ def init_steps(edition, platform, is_downstream=False, install_deps=True): ...@@ -266,8 +292,11 @@ def init_steps(edition, platform, is_downstream=False, install_deps=True):
] + common_cmds, ] + common_cmds,
}, },
] ]
if version_mode == 'master':
steps.append(slack_step(channel='grafana-enterprise-ci-failures'))
return steps
return [ steps = [
identify_runner_step, identify_runner_step,
{ {
'name': 'initialize', 'name': 'initialize',
...@@ -286,6 +315,11 @@ def init_steps(edition, platform, is_downstream=False, install_deps=True): ...@@ -286,6 +315,11 @@ def init_steps(edition, platform, is_downstream=False, install_deps=True):
}, },
] ]
if version_mode == 'master':
steps.append(slack_step(channel='grafana-ci-failures'))
return steps
def enterprise_downstream_step(edition): def enterprise_downstream_step(edition):
if edition == 'enterprise': if edition == 'enterprise':
return None return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment