Skip to content

Commit e6f59e7

Browse files
author
Manon Delahaye
committed
Add action epic.create using gitlab-python library
1 parent 77b62e6 commit e6f59e7

File tree

11 files changed

+87
-6
lines changed

11 files changed

+87
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v1.1.0
2+
3+
* Use of `python-gitlab` library
4+
* New action `epic.create`
5+
16
## v1.0.1
27

38
* Small bug fixes regarding Python 3 support

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ verify_ssl: False
1212
1313
## Actions
1414
15+
### Epics
16+
17+
* `epic.create` - Create new Epic
18+
1519
### Projects
1620

1721
* `project.info` - Returns project information
@@ -24,4 +28,3 @@ verify_ssl: False
2428

2529
* `pipeline.list` - List all pipelines in a project
2630
* `pipeline.trigger` - Create a new pipeline
27-

actions/epic_create.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
3+
from st2common.runners.base_action import Action
4+
import gitlab
5+
6+
7+
class GitlabEpicCreate(Action):
8+
9+
# Retrieve config information
10+
def __init__(self, config):
11+
super(GitlabEpicCreate, self).__init__(config=config)
12+
self.url = self.config.get('url')
13+
self.token = self.config.get('token')
14+
15+
def run(self, group_id, title, labels, description, start_date, due_date, token):
16+
17+
# Use user token if given
18+
token = token or self.token
19+
20+
# Initiate GitLab instance
21+
gl = gitlab.Gitlab(self.url, token)
22+
23+
# Get the group with id == group_id
24+
group = gl.groups.get(group_id)
25+
26+
# If start/due date is given, tell gitlab it is fixed
27+
due_date_is_fixed = True if due_date else False
28+
start_date_is_fixed = True if start_date else False
29+
30+
# Create new epic
31+
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})
32+
return (True, epic)

actions/epic_create.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
3+
name: epic.create
4+
description: "Create new Epic"
5+
6+
runner_type: python-script
7+
entry_point: epic_create.py
8+
9+
# Taken from https://docs.gitlab.com/ee/api/epics.html#new-epic
10+
parameters:
11+
group_id:
12+
description: "The ID of the group in which to create the epic"
13+
type: integer
14+
default: 117
15+
required: true
16+
position: 0
17+
title:
18+
description: "The title of the epic"
19+
type: string
20+
required: true
21+
position: 1
22+
labels:
23+
description: "The comma-separated list of labels"
24+
type: string
25+
position: 2
26+
description:
27+
description: "The description of the epic. Limited to 1,048,576 characters."
28+
type: string
29+
position: 3
30+
start_date:
31+
description: "The fixed start date of an epic"
32+
type: string
33+
position: 4
34+
due_date:
35+
description: "The fixed due date of an epic"
36+
type: string
37+
position: 5
38+
token:
39+
description: "Gitlab token"
40+
type: string

actions/issue_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from lib.gitlab import GitlabIssuesAPI
3+
from lib.gitlabLib import GitlabIssuesAPI
44

55

66
class GitlabIssue(GitlabIssuesAPI):
File renamed without changes.

actions/pipeline_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from lib.gitlab import GitlabPipelineAPI
3+
from lib.gitlabLib import GitlabPipelineAPI
44

55

66
class GitlabPipeline(GitlabPipelineAPI):

actions/pipeline_trigger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from lib.gitlab import GitlabPipelineAPI
3+
from lib.gitlabLib import GitlabPipelineAPI
44

55

66
class GitlabPipelineTrigger(GitlabPipelineAPI):

actions/project_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from lib.gitlab import GitlabProjectsAPI
3+
from lib.gitlabLib import GitlabProjectsAPI
44

55

66
class GitlabProject(GitlabProjectsAPI):

pack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: gitlab
33
description: GitLab Rest API
44
keywords:
55
- gitlab
6-
version: 1.0.1
6+
version: 1.1.0
77
author: Daniel Chamot
88
99
python_versions:

0 commit comments

Comments
 (0)