Sign in
agent:

Add this pod status as a code block in the Jira comment

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

This code adds the pod status as a code block in the specified Jira ticket using the Jira API.

import json import requests from requests.auth import HTTPBasicAuth # Get environment variables JIRA_USER_NAME = getEnvVar('JIRA_USER_NAME') JIRA_API_KEY = getEnvVar('JIRA_API_KEY') JIRA_BASE_URL = getEnvVar('JIRA_BASE_URL') # Print input parameters print(f"Input Parameters:\nissue_url: {issue_url}\npod_status: {pod_status}") # Extract issue key from issue URL issue_key = issue_url.split('/')[-1] # Jira API URL to add a comment to the issue url = f"{JIRA_BASE_URL}/rest/api/3/issue/{issue_key}/comment" # Headers for authentication headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' } # Format the pod status as a code block in Atlassian Document Format pod_status_adf = [{ "type": "codeBlock", "content": [ { "type": "text", "text": pod_status } ] }] # Payload to add a comment payload = { "body": { "type": "doc", "version": 1, "content": pod_status_adf } } # Make the request to Jira API to add the comment response = requests.post(url, headers=headers, auth=HTTPBasicAuth(JIRA_USER_NAME, JIRA_API_KEY), json=payload) if response.status_code == 201: comment_id = response.json()['id'] print(f"Output:\nComment added successfully with ID: {comment_id}") else: print(f"Failed to add comment. Status code: {response.status_code}")
copied