Sign in
agent:

Now take the commit log above and dump it in a new Jira ticket.

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

This code creates a new Jira ticket in the specified project and dumps the commit log in the description using the Jira API.

import json import requests from requests.auth import HTTPBasicAuth ticket_title = f"dev deployment of repo: {repo_name} and branch: {new_branch_name}" # 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:\nproject_key: {project_key}\nticket_title: {ticket_title}\ncommit_list: {json.dumps(commit_list, indent=4, default=str)}") # Jira API URL to create a new issue url = f"{JIRA_BASE_URL}/rest/api/3/issue" # Headers for authentication headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' } # Format the commit log in Atlassian Document Format commit_log_adf = [{ "type": "paragraph", "content": [ { "type": "text", "text": json.dumps(commit, indent=4) } ] } for commit in commit_list] # Payload to create a new issue payload = { "fields": { "project": { "key": project_key }, "summary": ticket_title, "description": { "type": "doc", "version": 1, "content": commit_log_adf }, "issuetype": { "name": "Task" } } } # Make the request to Jira API to create the new issue response = requests.post(url, headers=headers, auth=HTTPBasicAuth(JIRA_USER_NAME, JIRA_API_KEY), json=payload) if response.status_code == 201: issue_key = response.json()['key'] issue_url = f"{JIRA_BASE_URL}/browse/{issue_key}" print(f"Output:\n{json.dumps({'issue_url': issue_url}, indent=4, default=str)}") else: issue_url = None print(f"Failed to create Jira ticket. Status code: {response.status_code}") # Output the issue URL issue_url
copied