Skip to content
Snippets Groups Projects
Commit 30b4e65c authored by jurgenhaas's avatar jurgenhaas
Browse files

Fix bug in gitlab plugin and only execute when really an issue should be created

parent 16f6013c
Branches main
No related tags found
No related merge requests found
import gitlab
import json
import logging
import requests
import urllib.parse
from alerta.plugins import PluginBase, app
LOG = logging.getLogger('alerta.plugins')
......@@ -29,17 +27,18 @@ class GitlabIssue(PluginBase):
return alert, status, text
def take_action(self, alert, action, text, **kwargs):
"""should return internal id of external system"""
if action == 'createIssue':
"""should return internal id of external system"""
LOG.info('Create GitLab issue for %s' % alert.environment)
git = gitlab.Gitlab(GITLAB_URL, GITLAB_ACCESS_TOKEN, ssl_verify=True) # type: gitlab
git.auth()
project = git.projects.get('ansible-inventories/hosts/{}/{}'.format(alert.environment, alert.origin.split('/').pop()))
LOG.info('Create GitLab issue for %s' % alert.environment)
git = gitlab.Gitlab(GITLAB_URL, GITLAB_ACCESS_TOKEN, ssl_verify=True) # type: gitlab
git.auth()
project = git.projects.get('ansible-inventories/hosts/{}/{}'.format(alert.environment, alert.origin.split('/').pop()))
if project:
LOG.info('Project ID %s' % project.id)
if project:
LOG.info('Project ID %s' % project.id)
if action == 'createIssue':
if 'issue_iid' not in alert.attributes:
# noinspection PyBroadException
try:
......
from setuptools import find_packages, setup
version = '1.1.0'
version = '1.2.0'
setup(
name='alerta-gitlab',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment