Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## v1.0.1
## v1.0.2

* Added the rest of the integrations needed to completely manage gitlab issues.
* Added ability to get a file from a project.

* ## v1.0.1

* Small bug fixes regarding Python 3 support

Expand Down
27 changes: 27 additions & 0 deletions actions/issue.close.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

name: issue.close
description: "Close a GitLab issue"

runner_type: python-script
entry_point: issue_close.py

parameters:
url:
type: string
description: Override the configured base url for gitlab
project:
type: string
required: true
description: the 'path_with_namespace' for the project (e.g., group/group/project)
issue_iid:
type: string
required: true
description: the iid of the issue in the project (not global unique id)
token:
type: string
description: Override the configured token for the gitlab api
secret: true
verify_ssl:
type: boolean
default: False
36 changes: 36 additions & 0 deletions actions/issue.create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---

name: issue.create
description: "Create a new GitLab issue"

runner_type: python-script
entry_point: issue_create.py

parameters:
url:
type: string
description: Override the configured base url for gitlab
project:
type: string
required: true
description: the 'path_with_namespace' for the project (e.g., group/group/project)
title:
type: string
required: true
description: The issue title
description:
type: string
description: The issue description
assignee_ids:
type: string
description: Comma-separated list of user IDs to assign the issue to
labels:
type: string
description: Comma-separated list of label names
token:
type: string
description: Override the configured token for the gitlab api
secret: true
verify_ssl:
type: boolean
default: False
31 changes: 31 additions & 0 deletions actions/issue.list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---

name: issue.list
description: "List all issues for a project with filtering by state"

runner_type: python-script
entry_point: issue_list.py

parameters:
url:
type: string
description: Override the configured base url for gitlab
project:
type: string
required: true
description: the 'path_with_namespace' for the project (e.g., group/group/project)
state:
type: string
description: Filter issues by state
enum:
- opened
- closed
- all
default: all
token:
type: string
description: Override the configured token for the gitlab api
secret: true
verify_ssl:
type: boolean
default: False
31 changes: 31 additions & 0 deletions actions/issue.note.create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---

name: issue.note.create
description: "Add a note (comment) to a GitLab issue"

runner_type: python-script
entry_point: issue_note_create.py

parameters:
url:
type: string
description: Override the configured base url for gitlab
project:
type: string
required: true
description: the 'path_with_namespace' for the project (e.g., group/group/project)
issue_iid:
type: string
required: true
description: the iid of the issue in the project (not global unique id)
body:
type: string
required: true
description: The content of the note/comment
token:
type: string
description: Override the configured token for the gitlab api
secret: true
verify_ssl:
type: boolean
default: False
27 changes: 27 additions & 0 deletions actions/issue.notes.list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

name: issue.notes.list
description: "List all notes (comments) on a GitLab issue"

runner_type: python-script
entry_point: issue_notes_list.py

parameters:
url:
type: string
description: Override the configured base url for gitlab
project:
type: string
required: true
description: the 'path_with_namespace' for the project (e.g., group/group/project)
issue_iid:
type: string
required: true
description: the iid of the issue in the project (not global unique id)
token:
type: string
description: Override the configured token for the gitlab api
secret: true
verify_ssl:
type: boolean
default: False
30 changes: 30 additions & 0 deletions actions/issue.reopen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

name: issue.reopen
description: "Reopen a closed GitLab issue with optional description update"

runner_type: python-script
entry_point: issue_reopen.py

parameters:
url:
type: string
description: Override the configured base url for gitlab
project:
type: string
required: true
description: the 'path_with_namespace' for the project (e.g., group/group/project)
issue_iid:
type: string
required: true
description: the iid of the issue in the project (not global unique id)
description:
type: string
description: Optional new description for the issue when reopening
token:
type: string
description: Override the configured token for the gitlab api
secret: true
verify_ssl:
type: boolean
default: False
39 changes: 39 additions & 0 deletions actions/issue.update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

name: issue.update
description: "Update an existing GitLab issue"

runner_type: python-script
entry_point: issue_update.py

parameters:
url:
type: string
description: Override the configured base url for gitlab
project:
type: string
required: true
description: the 'path_with_namespace' for the project (e.g., group/group/project)
issue_iid:
type: string
required: true
description: the iid of the issue in the project (not global unique id)
title:
type: string
description: The new issue title
description:
type: string
description: The new issue description
assignee_ids:
type: string
description: Comma-separated list of user IDs to assign the issue to (empty string to clear)
labels:
type: string
description: Comma-separated list of label names (empty string to clear)
token:
type: string
description: Override the configured token for the gitlab api
secret: true
verify_ssl:
type: boolean
default: False
26 changes: 26 additions & 0 deletions actions/issue_close.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python

from lib.gitlab import GitlabIssuesAPI


class GitlabIssueClose(GitlabIssuesAPI):

def run(self, url, project, issue_iid, token, verify_ssl):
self.url = url or self.url
self.verify_ssl = verify_ssl or self.verify_ssl
self.token = token or self.token

issue = self.close(self.url, project, issue_iid)

# Return formatted response
result = {
'id': issue.get('iid'),
'global_id': issue.get('id'),
'title': issue.get('title'),
'state': issue.get('state'),
'web_url': issue.get('web_url'),
'updated_at': issue.get('updated_at'),
'closed_at': issue.get('closed_at')
}

return True, result
53 changes: 53 additions & 0 deletions actions/issue_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python

from lib.gitlab import GitlabIssuesAPI


class GitlabIssueCreate(GitlabIssuesAPI):

def run(self, url, project, title, description, assignee_ids, labels, token, verify_ssl):
self.url = url or self.url
self.verify_ssl = verify_ssl or self.verify_ssl
self.token = token or self.token

# Parse assignee_ids if provided as comma-separated string
parsed_assignee_ids = None
if assignee_ids:
if isinstance(assignee_ids, str):
parsed_assignee_ids = [
int(aid.strip()) for aid in assignee_ids.split(',')
]
elif isinstance(assignee_ids, list):
parsed_assignee_ids = [int(aid) for aid in assignee_ids]

# Parse labels if provided as comma-separated string
parsed_labels = None
if labels:
if isinstance(labels, str):
parsed_labels = [
label.strip() for label in labels.split(',')
]
elif isinstance(labels, list):
parsed_labels = labels

issue = self.create(
self.url,
project,
title,
description=description,
assignee_ids=parsed_assignee_ids,
labels=parsed_labels
)

# Return formatted response
result = {
'id': issue.get('iid'),
'global_id': issue.get('id'),
'title': issue.get('title'),
'description': issue.get('description'),
'state': issue.get('state'),
'web_url': issue.get('web_url'),
'created_at': issue.get('created_at')
}

return True, result
27 changes: 27 additions & 0 deletions actions/issue_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python

from lib.gitlab import GitlabIssuesAPI


class GitlabIssueList(GitlabIssuesAPI):

def run(self, url, project, state, token, verify_ssl):
self.url = url or self.url
self.verify_ssl = verify_ssl or self.verify_ssl
self.token = token or self.token

issues = self.list(self.url, project, state=state)

# Format the response to include name (title), ID (iid), and status (state)
formatted_issues = []
for issue in issues:
formatted_issues.append({
'name': issue.get('title'),
'id': issue.get('iid'),
'status': issue.get('state'),
'web_url': issue.get('web_url'),
'created_at': issue.get('created_at'),
'updated_at': issue.get('updated_at')
})

return True, formatted_issues
29 changes: 29 additions & 0 deletions actions/issue_note_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python

from lib.gitlab import GitlabIssuesAPI


class GitlabIssueNoteCreate(GitlabIssuesAPI):

def run(self, url, project, issue_iid, body, token, verify_ssl):
self.url = url or self.url
self.verify_ssl = verify_ssl or self.verify_ssl
self.token = token or self.token

note = self.create_note(self.url, project, issue_iid, body)

# Return formatted response
result = {
'id': note.get('id'),
'body': note.get('body'),
'author': {
'id': note.get('author', {}).get('id'),
'username': note.get('author', {}).get('username'),
'name': note.get('author', {}).get('name')
},
'created_at': note.get('created_at'),
'noteable_type': note.get('noteable_type'),
'noteable_iid': note.get('noteable_iid')
}

return True, result
Loading
Loading