mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CI: Notify channel on drone yaml changes (#42428)
* Notify on drone yaml changes * Change secrets * Remove test notification * Fix typo
This commit is contained in:
committed by
GitHub
parent
95831e9be0
commit
54ea2ed766
@@ -49,6 +49,8 @@ load(
|
||||
'scripts/drone/utils/utils.star',
|
||||
'pipeline',
|
||||
'notify_pipeline',
|
||||
'failure_template',
|
||||
'drone_change_template',
|
||||
)
|
||||
|
||||
ver_mode = 'main'
|
||||
@@ -142,6 +144,18 @@ def main_pipelines(edition):
|
||||
'event': ['push',],
|
||||
'branch': 'main',
|
||||
}
|
||||
drone_change_trigger = {
|
||||
'event': ['push',],
|
||||
'branch': 'main',
|
||||
'paths': {
|
||||
'include': [
|
||||
'.drone.yml',
|
||||
],
|
||||
'exclude': [
|
||||
'exclude',
|
||||
],
|
||||
},
|
||||
}
|
||||
steps, windows_steps, publish_steps = get_steps(edition=edition)
|
||||
|
||||
if edition == 'enterprise':
|
||||
@@ -157,6 +171,8 @@ def main_pipelines(edition):
|
||||
name='windows-main', edition=edition, trigger=trigger,
|
||||
steps=initialize_step(edition, platform='windows', ver_mode=ver_mode) + windows_steps,
|
||||
depends_on=['build-main'], platform='windows',
|
||||
), notify_pipeline(
|
||||
name='notify-drone-changes', slack_channel='slack-webhooks-test', trigger=drone_change_trigger, template=drone_change_template, secret='drone-changes-webhook',
|
||||
),
|
||||
]
|
||||
if edition != 'enterprise':
|
||||
@@ -167,8 +183,8 @@ def main_pipelines(edition):
|
||||
))
|
||||
|
||||
pipelines.append(notify_pipeline(
|
||||
name='notify-main', slack_channel='grafana-ci-notifications', trigger=trigger,
|
||||
depends_on=['build-main', 'windows-main', 'publish-main'],
|
||||
name='notify-main', slack_channel='grafana-ci-notifications', trigger=dict(trigger, status = ['failure']),
|
||||
depends_on=['build-main', 'windows-main', 'publish-main'], template=failure_template, secret='slack_webhook'
|
||||
))
|
||||
else:
|
||||
# Add downstream enterprise pipelines triggerable from OSS builds
|
||||
@@ -192,8 +208,8 @@ def main_pipelines(edition):
|
||||
))
|
||||
|
||||
pipelines.append(notify_pipeline(
|
||||
name='notify-main-downstream', slack_channel='grafana-enterprise-ci-notifications', trigger=trigger,
|
||||
depends_on=['build-main-downstream', 'windows-main-downstream', 'publish-main-downstream'],
|
||||
name='notify-main-downstream', slack_channel='grafana-enterprise-ci-notifications', trigger=dict(trigger, status = ['failure']),
|
||||
depends_on=['build-main-downstream', 'windows-main-downstream', 'publish-main-downstream'], template=failure_template, secret='slack_webhook',
|
||||
))
|
||||
|
||||
return pipelines
|
||||
|
||||
@@ -40,7 +40,10 @@ load(
|
||||
|
||||
load(
|
||||
'scripts/drone/utils/utils.star',
|
||||
'notify_pipeline',
|
||||
'pipeline',
|
||||
'failure_template',
|
||||
'drone_change_template',
|
||||
)
|
||||
|
||||
ver_mode = 'pr'
|
||||
@@ -109,7 +112,6 @@ def pr_pipelines(edition):
|
||||
build_steps.extend([
|
||||
package_step(edition=edition2, ver_mode=ver_mode, include_enterprise2=include_enterprise2, variants=['linux-x64']),
|
||||
e2e_tests_server_step(edition=edition2, port=3002),
|
||||
e2e_tests_step(edition=edition2, port=3002),
|
||||
e2e_tests_step('dashboards-suite', edition=edition2, port=3002),
|
||||
e2e_tests_step('smoke-tests-suite', edition=edition2, port=3002),
|
||||
e2e_tests_step('panels-suite', edition=edition2, port=3002),
|
||||
|
||||
@@ -48,6 +48,8 @@ load(
|
||||
'scripts/drone/utils/utils.star',
|
||||
'pipeline',
|
||||
'notify_pipeline',
|
||||
'failure_template',
|
||||
'drone_change_template',
|
||||
)
|
||||
|
||||
def release_npm_packages_step(edition, ver_mode):
|
||||
@@ -227,8 +229,8 @@ def release_pipelines(ver_mode='release', trigger=None):
|
||||
pipelines.append(publish_pipeline)
|
||||
|
||||
pipelines.append(notify_pipeline(
|
||||
name='notify-{}'.format(ver_mode), slack_channel='grafana-ci-notifications', trigger=trigger,
|
||||
depends_on=[p['name'] for p in pipelines],
|
||||
name='notify-{}'.format(ver_mode), slack_channel='grafana-ci-notifications', trigger=dict(trigger, status = ['failure']),
|
||||
depends_on=[p['name'] for p in pipelines], template=failure_template, secret='slack_webhook',
|
||||
))
|
||||
|
||||
return pipelines
|
||||
@@ -260,8 +262,8 @@ def test_release_pipelines():
|
||||
pipelines = oss_pipelines + enterprise_pipelines + [publish_pipeline,]
|
||||
|
||||
pipelines.append(notify_pipeline(
|
||||
name='notify-{}'.format(ver_mode), slack_channel='grafana-ci-notifications', trigger=trigger,
|
||||
depends_on=[p['name'] for p in pipelines],
|
||||
name='notify-{}'.format(ver_mode), slack_channel='grafana-ci-notifications', trigger=dict(trigger, status = ['failure']),
|
||||
depends_on=[p['name'] for p in pipelines], template=failure_template, secret='slack_webhook',
|
||||
))
|
||||
|
||||
return pipelines
|
||||
|
||||
@@ -12,14 +12,14 @@ wix_image = 'grafana/ci-wix:0.1.1'
|
||||
test_release_ver = 'v7.3.0-test'
|
||||
|
||||
|
||||
def slack_step(channel):
|
||||
def slack_step(channel, template, secret):
|
||||
return {
|
||||
'name': 'slack',
|
||||
'image': 'plugins/slack',
|
||||
'settings': {
|
||||
'webhook': from_secret('slack_webhook'),
|
||||
'webhook': from_secret(secret),
|
||||
'channel': channel,
|
||||
'template': 'Build {{build.number}} failed for commit: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 8 }}>: {{build.link}}\nBranch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>\nAuthor: {{build.author}}',
|
||||
'template': template,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ load(
|
||||
|
||||
load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token')
|
||||
|
||||
failure_template = 'Build {{build.number}} failed for commit: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 8 }}>: {{build.link}}\nBranch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>\nAuthor: {{build.author}}'
|
||||
drone_change_template = '`.drone.yml` and `starlark` files have been changed on the OSS repo, by: {{build.author}}. \nBranch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>\nCommit hash: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 8 }}>'
|
||||
|
||||
def pipeline(
|
||||
name, edition, trigger, steps, services=[], platform='linux', depends_on=[],
|
||||
):
|
||||
@@ -54,8 +57,8 @@ def pipeline(
|
||||
|
||||
return pipeline
|
||||
|
||||
def notify_pipeline(name, slack_channel, trigger, depends_on=[]):
|
||||
trigger = dict(trigger, status = ['failure'])
|
||||
def notify_pipeline(name, slack_channel, trigger, depends_on=[], template=None, secret=None):
|
||||
trigger = dict(trigger)
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
@@ -66,7 +69,7 @@ def notify_pipeline(name, slack_channel, trigger, depends_on=[]):
|
||||
'name': name,
|
||||
'trigger': trigger,
|
||||
'steps': [
|
||||
slack_step(slack_channel),
|
||||
slack_step(slack_channel, template, secret),
|
||||
],
|
||||
'depends_on': depends_on,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user