Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ansible/roles/alerta
1 result
Show changes
Commits on Source (1)
......@@ -37,7 +37,7 @@ class GitlabIssue(PluginBase):
ssl_verify=True) # type: gitlab
git.auth()
if 'gitlab_project_id' in alert.attributes:
if 'gitlab_project_id' in alert.attributes and alert.attributes['gitlab_project_id'] != 'None':
project = git.projects.get(
alert.attributes['gitlab_project_id'])
else:
......@@ -45,10 +45,17 @@ class GitlabIssue(PluginBase):
if projects:
project = projects[0]
else:
project = git.projects.get(
'ansible-inventories/hosts/{}/{}'.format(
alert.environment,
alert.origin.split('/').pop()))
try:
project = git.projects.get(
'ansible-inventories/hosts/{}/{}'.format(
alert.environment,
alert.origin.split('/').pop()))
except Exception as e:
project = git.projects.get(
'ansible-inventories/hosts/{}/{}'.format(
alert.environment,
alert.resource))
if project:
LOG.info('Project ID %s' % project.id)
......@@ -63,10 +70,11 @@ class GitlabIssue(PluginBase):
raw_data = alert.raw_data
issue = project.issues.create({
'title': alert.text[0:128],
'description': '{}/alert/{}\n\nService: {}\n\nOrigin: '
'{}\n\n```\n{}\n```\n'.format(
'description': '{}/alert/{}\n\nService: {}\n\nOrigin: {}'
'\n\nEvent: {}\n\nValue: {}'
'\n\n```\n{}\n```\n'.format(
ALERTA_URL, alert.id, alert.service, alert.origin,
raw_data)
alert.event, alert.value, raw_data)
}) # type: Issue
alert.attributes['issue_iid'] = issue.id
alert.attributes['gitlabUrl'] = \
......
from setuptools import find_packages, setup
version = '1.3.1'
version = '1.3.2'
setup(
name='alerta-gitlab',
......