Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alerta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ansible
Roles
alerta
Commits
30b4e65c
Commit
30b4e65c
authored
5 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/gitlab/alerta_gitlab.py
+9
-10
9 additions, 10 deletions
templates/gitlab/alerta_gitlab.py
templates/gitlab/setup.py
+1
-1
1 addition, 1 deletion
templates/gitlab/setup.py
with
10 additions
and
11 deletions
templates/gitlab/alerta_gitlab.py
+
9
−
10
View file @
30b4e65c
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
:
...
...
This diff is collapsed.
Click to expand it.
templates/gitlab/setup.py
+
1
−
1
View file @
30b4e65c
from
setuptools
import
find_packages
,
setup
version
=
'
1.
1
.0
'
version
=
'
1.
2
.0
'
setup
(
name
=
'
alerta-gitlab
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment