This is the code to attach the video to the description that video already in the attachments need to append the video to be playable
def update_results_section(issue_key, section_name, file_urls):
"""
Updates a specific section of a Jira issue with video URLs embedded as previews using HTML iframes.
:param issue_key: The Jira issue key
:param section_name: The section name to update (e.g., 'Actual Results', 'Expected Results')
:param file_urls: List of video URLs to add to the section
"""
if not file_urls:
print(f"No file URLs provided to update the '{section_name}' section.")
return
# Retrieve issue details
jira_get_issue_url = f"{jira_base_url}/rest/api/2/issue/{issue_key}"
response = requests.get(jira_get_issue_url, auth=(jira_username, jira_api_token))
if response.status_code != 200:
print(f"Failed to retrieve issue details for {issue_key} (Status Code: {response.status_code}).")
return
issue_data = response.json()
current_description = issue_data['fields'].get('description', "")
# Check if the section exists
section_header = f"*{section_name}:*"
video_section = "n".join([f"<h2>Video Preview</h2><a href='{url}' target='_blank'>{url}</a>" for url in file_urls])
if section_header in current_description:
print(f"Found '{section_name}' section in the description. Appending videos...")
start_idx = current_description.find(section_header) + len(section_header)
before_append = current_description[:start_idx].strip()
after_append = current_description[start_idx:].strip()
updated_description = (
f"{before_append}n"
+ "n".join([f"<h2>Video Preview</h2><a href='{url}' target='_blank'>{url}</a>" for url in file_urls])
+ f"n{after_append}"
)
else:
print(f"'{section_name}' section not found. Adding a new section.")
updated_description = current_description + f"nn{section_header}n"
updated_description += video_section
# Prepare payload and update
update_payload = {"fields": {"description": updated_description}}
jira_update_url = f"{jira_base_url}/rest/api/2/issue/{issue_key}"
try:
update_response = requests.put(
jira_update_url,
headers={"Content-Type": "application/json"},
auth=(jira_username, jira_api_token),
data=json.dumps(update_payload)
)
if update_response.status_code == 204:
print(f"Successfully updated the '{section_name}' section for issue {issue_key}.n")
messagebox.showinfo("Confirmation", "Videos have been successfully attached!")
else:
print(f"Failed to update issue {issue_key} (Status Code: {update_response.status_code}).")
print(update_response.text)
except requests.exceptions.RequestException as e:
print(f"An error occurred while updating the issue: {e}")
i tried it using markdown symbol and it cannot be playable it can only add as clickable link how to add the video to be playablein the Actual Result Section
New contributor
Sudam Praveen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.