将现有的JIRA票/问题分配给Python的用户

发布于 2025-01-25 21:00:00 字数 827 浏览 3 评论 0原文

我正在尝试使用Python分配现有的JIRA票。尝试了以下方法,但没有一种方法正在起作用。我可以添加评论,但没有分配问题

    #Method 1 Using Jira library - Getting JiraError HTTP None, text list index out of range
    from jira import JIRA
    jira_connection = JIRA(basic_auth=(username,password),server)
    issue = jira_connection.issue('100')
    jira_connection.assign_issue(issue,user_name)

    #Tried below way as well 
    issue.update(assignee={'accountId':'natash5'})


    #Method 2 Using Servicedesk - the update_issue_field function was empty in the source code
    from atlassian import ServiceDesk
    sd = ServiceDesk(url= "")
    sd.update_issue_field('100',{'assignee':'user_name')

    #Method 3 Soap API - SAXParse exception invalid token
    from suds import Client
    cl = Client(url)
    auth = cl.service.login(username,password)

I'm trying to assign a existing jira ticket using python. Tried the below methods , but none are working. I'm able to add comments but not assign the issue

    #Method 1 Using Jira library - Getting JiraError HTTP None, text list index out of range
    from jira import JIRA
    jira_connection = JIRA(basic_auth=(username,password),server)
    issue = jira_connection.issue('100')
    jira_connection.assign_issue(issue,user_name)

    #Tried below way as well 
    issue.update(assignee={'accountId':'natash5'})


    #Method 2 Using Servicedesk - the update_issue_field function was empty in the source code
    from atlassian import ServiceDesk
    sd = ServiceDesk(url= "")
    sd.update_issue_field('100',{'assignee':'user_name')

    #Method 3 Soap API - SAXParse exception invalid token
    from suds import Client
    cl = Client(url)
    auth = cl.service.login(username,password)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赢得她心 2025-02-01 21:00:00
import requests
from requests.auth import HTTPBasicAuth
import json

url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/assignee"

auth = HTTPBasicAuth("[email protected]", "<api_token>")

headers = {
    "Accept": "application/json",
    "Content-Type": "application/json"
}

payload = json.dumps( {
    "accountId": "5b10ac8d82e05b22cc7d4ef5"
} )

response = requests.request(
    "PUT",
    url,
    data=payload,
    headers=headers,
    auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

我遇到了同一问题,请自己使用端点,而不是 - https://develoverer.atlassian.com/cloud/jira/jira/platform/rest/rest/rest/v3/api-group-group-group-group-group-group-sissues/#api -rest-api-3-issue-issueidorkey-assignee-put
如果您有兴趣,我将放置一个在其中包含很多这些东西的仓库,以及完成工作的方法。在其中仍然可以整理很多东西,所以请承认这是一个beta版本:) https://github.com/ dren79/jirascripting_public

import requests
from requests.auth import HTTPBasicAuth
import json

url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/assignee"

auth = HTTPBasicAuth("[email protected]", "<api_token>")

headers = {
    "Accept": "application/json",
    "Content-Type": "application/json"
}

payload = json.dumps( {
    "accountId": "5b10ac8d82e05b22cc7d4ef5"
} )

response = requests.request(
    "PUT",
    url,
    data=payload,
    headers=headers,
    auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

I've run into the same issue, use the endpoints yourself rather than the - https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-assignee-put
If you're interested I'm putting together a repo that has a lot of this stuff in it with ways to get stuff done. There is still a lot to tidy up in it so conceder this a beta release :) https://github.com/dren79/JiraScripting_public

素食主义者 2025-02-01 21:00:00
import psutil
import socket
from datetime import datetime

def get_running_processes(name=None):
    process_list = []  # Use a list to store processes
    hostname = socket.gethostname()  # Get the hostname of the machine
    current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')  # Get current datetime as a string

    for process in psutil.process_iter(['pid', 'name', 'username']):
        try:
            process_info = process.as_dict(attrs=['pid', 'name', 'username'])
            if name is None or process_info['name'] == name:
                process_info['hostname'] = hostname
                process_info['timestamp'] = current_time
                process_info['status'] = 'Not Available' if process_info['name'] == 'notepad.exe' else 'Available'
                process_list.append(process_info)
        except psutil.NoSuchProcess:
            pass

    return process_list

if __name__ == "__main__":
    processes_list = get_running_processes(name="notepad.exe")
    print(processes_list)
import psutil
import socket
from datetime import datetime

def get_running_processes(name=None):
    process_list = []  # Use a list to store processes
    hostname = socket.gethostname()  # Get the hostname of the machine
    current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')  # Get current datetime as a string

    for process in psutil.process_iter(['pid', 'name', 'username']):
        try:
            process_info = process.as_dict(attrs=['pid', 'name', 'username'])
            if name is None or process_info['name'] == name:
                process_info['hostname'] = hostname
                process_info['timestamp'] = current_time
                process_info['status'] = 'Not Available' if process_info['name'] == 'notepad.exe' else 'Available'
                process_list.append(process_info)
        except psutil.NoSuchProcess:
            pass

    return process_list

if __name__ == "__main__":
    processes_list = get_running_processes(name="notepad.exe")
    print(processes_list)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文