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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, that I didn't use jiraone as I found the solution myself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.