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
Compare revisions
fdde06ec7f20a0e1436ddcfd4157ed6b5a9f3630 to a679b1df0de81c88ea572427dcb65ffb7fbce7cd
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
ansible/roles/alerta
Select target project
No results found
a679b1df0de81c88ea572427dcb65ffb7fbce7cd
Select Git revision
Swap
Target
ansible/roles/alerta
Select target project
ansible/roles/alerta
1 result
fdde06ec7f20a0e1436ddcfd4157ed6b5a9f3630
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
ansible-inventories/bitegra#40 Improve project detection for alerts
· a679b1df
jurgenhaas
authored
4 years ago
a679b1df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/plugins/gitlab/plugin.py
+16
-8
16 additions, 8 deletions
templates/plugins/gitlab/plugin.py
templates/plugins/gitlab/setup.py
+1
-1
1 addition, 1 deletion
templates/plugins/gitlab/setup.py
with
17 additions
and
9 deletions
templates/plugins/gitlab/plugin.py
View file @
a679b1df
...
@@ -37,7 +37,7 @@ class GitlabIssue(PluginBase):
...
@@ -37,7 +37,7 @@ class GitlabIssue(PluginBase):
ssl_verify
=
True
)
# type: gitlab
ssl_verify
=
True
)
# type: gitlab
git
.
auth
()
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
(
project
=
git
.
projects
.
get
(
alert
.
attributes
[
'
gitlab_project_id
'
])
alert
.
attributes
[
'
gitlab_project_id
'
])
else
:
else
:
...
@@ -45,10 +45,17 @@ class GitlabIssue(PluginBase):
...
@@ -45,10 +45,17 @@ class GitlabIssue(PluginBase):
if
projects
:
if
projects
:
project
=
projects
[
0
]
project
=
projects
[
0
]
else
:
else
:
project
=
git
.
projects
.
get
(
try
:
'
ansible-inventories/hosts/{}/{}
'
.
format
(
project
=
git
.
projects
.
get
(
alert
.
environment
,
'
ansible-inventories/hosts/{}/{}
'
.
format
(
alert
.
origin
.
split
(
'
/
'
).
pop
()))
alert
.
environment
,
alert
.
origin
.
split
(
'
/
'
).
pop
()))
except
Exception
as
e
:
project
=
git
.
projects
.
get
(
'
ansible-inventories/hosts/{}/{}
'
.
format
(
alert
.
environment
,
alert
.
resource
))
if
project
:
if
project
:
LOG
.
info
(
'
Project ID %s
'
%
project
.
id
)
LOG
.
info
(
'
Project ID %s
'
%
project
.
id
)
...
@@ -63,10 +70,11 @@ class GitlabIssue(PluginBase):
...
@@ -63,10 +70,11 @@ class GitlabIssue(PluginBase):
raw_data
=
alert
.
raw_data
raw_data
=
alert
.
raw_data
issue
=
project
.
issues
.
create
({
issue
=
project
.
issues
.
create
({
'
title
'
:
alert
.
text
[
0
:
128
],
'
title
'
:
alert
.
text
[
0
:
128
],
'
description
'
:
'
{}/alert/{}
\n\n
Service: {}
\n\n
Origin:
'
'
description
'
:
'
{}/alert/{}
\n\n
Service: {}
\n\n
Origin: {}
'
'
{}
\n\n
```
\n
{}
\n
```
\n
'
.
format
(
'
\n\n
Event: {}
\n\n
Value: {}
'
'
\n\n
```
\n
{}
\n
```
\n
'
.
format
(
ALERTA_URL
,
alert
.
id
,
alert
.
service
,
alert
.
origin
,
ALERTA_URL
,
alert
.
id
,
alert
.
service
,
alert
.
origin
,
raw_data
)
alert
.
event
,
alert
.
value
,
raw_data
)
})
# type: Issue
})
# type: Issue
alert
.
attributes
[
'
issue_iid
'
]
=
issue
.
id
alert
.
attributes
[
'
issue_iid
'
]
=
issue
.
id
alert
.
attributes
[
'
gitlabUrl
'
]
=
\
alert
.
attributes
[
'
gitlabUrl
'
]
=
\
...
...
This diff is collapsed.
Click to expand it.
templates/plugins/gitlab/setup.py
View file @
a679b1df
from
setuptools
import
find_packages
,
setup
from
setuptools
import
find_packages
,
setup
version
=
'
1.3.
1
'
version
=
'
1.3.
2
'
setup
(
setup
(
name
=
'
alerta-gitlab
'
,
name
=
'
alerta-gitlab
'
,
...
...
This diff is collapsed.
Click to expand it.