Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Python API and getting/setting epic color

TLDR; How do I get and set epic colors from Python?

According to https://confluence.atlassian.com/jirakb/editing-colors-through-epic-color-field-in-jira-1047551293.html I can see that when we select a color for an epic in Jira, we're actually assigning one of the preset values to a custom field called "Epic Color", such as "ghx-label-7". That page goes on to specify a LUT for what RGB colour each "ghx-label-#" maps to.

Using the Python API, I am able to obtain the ID of this custom field:

# Get the custom field ID by label
def get_custom_field_id_by_label(label):
custom_fields = jira.fields()
for field in custom_fields:
if field['name'] == label:
return field['id']
return None

 which in my case returns "customfield_10013".

My problem is, I cannot see how I can either read the value of this field on any given epic (it isn't listed as any of the fields associated) or set it (I get errors about being on the wrong "screen").

For example:

 json = jira.search_issues(f"id='{issue.key}'", maxResults=1, json_result=True)

I can see when looking at everything that's associated with a given issue (which I know for a fact I set the color of this epic via the GUI) I do not see any field matching customfield_10013 nor do I see anything with a value looking like "ghx-label-#".

So it's no surprise that I am unable to figure out what color the epic is when I do something along these lines:

for key, value in first_issue['fields'].items():
if key == custom_field_id:
print(key, value)

Any attempt to set/add the value of this field on an issue results in errors of this sort:

text: Field 'customfield_10013' cannot be set. It is not on the appropriate screen, or unknown.

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events