Skip to content

Commit cf7763b

Browse files
authored
Create jira_add_label_tag.py (#683)
1 parent 1b4ca92 commit cf7763b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# coding=utf-8
2+
from atlassian import Jira
3+
4+
# This example shoes how to add an additional value to the Labels field
5+
# without loosing the previously defined ones already defined
6+
7+
issue_key = "TST-1"
8+
new_tag = "label_to_add_for_test"
9+
jira = Jira(url="http://localhost:8080", username="admin", password="admin")
10+
11+
12+
def jira_add_label(issue_key, new_tag):
13+
field_name = "labels"
14+
# get value and save
15+
field_value = jira.issue_field_value(issue_key, field_name)
16+
field_value.append(new_tag)
17+
# prepare data like this
18+
# https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-edit-issues-6291632
19+
field_preparation = {field_name: field_value}
20+
# update custom field on destination issue
21+
jira.update_issue_field(issue_key, field_preparation)
22+
23+
24+
jira_add_label(issue_key, new_tag)

0 commit comments

Comments
 (0)