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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I append multiple fixversions using python jira rest api ? Edited

issue.update(fields={'fixVersions':[{'name':current_fixVs[0]},{'name':current_fixVs[1]},{'name':current_fixVs[2]},{'name':current_fixVs[3]}]})

considering 4 fix versions the above code works without overwriting(acutally overwrites) existing because I fetch the existing fixversion and append(otherwise it overwrites) to the array.

But I cannot keep updating the code by adding another element from the array - current_fixVs[4] as the number of fix versions will dynamically change. Also, the api won't accept a single array(containing all fixversions) to be added as fixversion.

2 answers

Hi @Arjun Eswaran I'm not Python developer, but can you try to share bigger part of the code?

def update_fixversion(issue, fixV):
print(issue)
rel = issue.fields.customfield_10390
rep = issue.fields.reporter.name
for item in rel:
variant = item.value
if 'Fixed' in issue.fields.status.name and issue.fields.fixVersions is None:
issue.update(fields={'fixVersions':fixV})
jira.transition_issue(issue, transition='Integrate fix')
elif 'Verified' in issue.fields.status.name and issue.fields.fixVersions is not None:
for fvs in issue.fields.fixVersions:
current_fixVs.append(fvs)
current_fixVs.append(fixV)
try:
issue.update(fields={'fixVersions':[{'name':current_fixVs[0]},{'name':current_fixVs[1]},{'name':current_fixVs[2]},{'name':current_fixVs[3]}]})
except IndexError:
pass
0 votes

Hi @Arjun Eswaran 

Welcome to community! Those type of fields are a bit tricky to work with. However I have a script called jiraone that could help with updating the field options on various issues while maintaining the previous values. It has a field variable you can use to call defined methods used for updating Jira fields. You can try it for your server instance by looking at the method.

You can install via pypi by using.

pip install jiraone

For more details on the parameters, you can refer to the documentation here. Hope this can help you with your use case.

Thank you.

Do I need to rewrite entire script?

No, you just need to simply make a call to the method field.update_field_data() 

Example usage:

from jiraone import field, LOGIN

user = "username"
password = "password"
link = "https://<serverinstance>.com"
LOGIN(user=user, password=password, url=link)

issue = "T6-75"  # issue key
fields = "Fix versions" # a fix version system field
case_value = ["COM Row 1", "Thanos"] for value in case_value: c = field.update_field_data(data=value, find_field=fields, key_or_id=issue,
options="add", show=False, field_type="system") print(c)

I haven't tested it properly on servers but Jira is basically the same software and the payload should be the same. You can add a list and loop over it as shown above or if you intend to add or remove just one item, then add it as a string.

Sorry, that I didn't use jiraone as I found the solution myself.

 

if 'Fixed' in issue.fields.status.name and issue.fields.fixVersions is None:
issue.update(fields={'fixVersions':fixV})
jira.transition_issue(issue, transition='Integrate fix')
rep = my_issues.fields.reporter.name
elif 'Verified' in issue.fields.status.name and issue.fields.fixVersions is not None:
for fvs in issue.fields.fixVersions:
all_fixvs.append({'name':fvs.name})
all_fixvs.append({'name':fixV})
try:
issue.update(fields={'fixVersions':all_fixvs})
except IndexError:
pass
Like Prince Nyeche likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you