-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add action epic.create using gitlab-python library
- Loading branch information
Manon Delahaye
committed
Jan 26, 2024
1 parent
77b62e6
commit e6f59e7
Showing
11 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
|
||
from st2common.runners.base_action import Action | ||
import gitlab | ||
|
||
|
||
class GitlabEpicCreate(Action): | ||
|
||
# Retrieve config information | ||
def __init__(self, config): | ||
super(GitlabEpicCreate, self).__init__(config=config) | ||
self.url = self.config.get('url') | ||
self.token = self.config.get('token') | ||
|
||
def run(self, group_id, title, labels, description, start_date, due_date, token): | ||
|
||
# Use user token if given | ||
token = token or self.token | ||
|
||
# Initiate GitLab instance | ||
gl = gitlab.Gitlab(self.url, token) | ||
|
||
# Get the group with id == group_id | ||
group = gl.groups.get(group_id) | ||
|
||
# If start/due date is given, tell gitlab it is fixed | ||
due_date_is_fixed = True if due_date else False | ||
start_date_is_fixed = True if start_date else False | ||
|
||
# Create new epic | ||
epic = group.epics.create({'title': title, 'description': description, 'labels': labels, 'start_date_fixed': start_date, 'start_date_is_fixed': start_date_is_fixed, 'due_date_fixed': due_date, 'due_date_is_fixed': due_date_is_fixed}) | ||
return (True, epic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
|
||
name: epic.create | ||
description: "Create new Epic" | ||
|
||
runner_type: python-script | ||
entry_point: epic_create.py | ||
|
||
# Taken from https://docs.gitlab.com/ee/api/epics.html#new-epic | ||
parameters: | ||
group_id: | ||
description: "The ID of the group in which to create the epic" | ||
type: integer | ||
default: 117 | ||
required: true | ||
position: 0 | ||
title: | ||
description: "The title of the epic" | ||
type: string | ||
required: true | ||
position: 1 | ||
labels: | ||
description: "The comma-separated list of labels" | ||
type: string | ||
position: 2 | ||
description: | ||
description: "The description of the epic. Limited to 1,048,576 characters." | ||
type: string | ||
position: 3 | ||
start_date: | ||
description: "The fixed start date of an epic" | ||
type: string | ||
position: 4 | ||
due_date: | ||
description: "The fixed due date of an epic" | ||
type: string | ||
position: 5 | ||
token: | ||
description: "Gitlab token" | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name: gitlab | |
description: GitLab Rest API | ||
keywords: | ||
- gitlab | ||
version: 1.0.1 | ||
version: 1.1.0 | ||
author: Daniel Chamot | ||
email: [email protected] | ||
python_versions: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
requests | ||
python-gitlab |