jira-issues
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJira Issue Management
Jira问题管理
Create and manage Jira issues using the Jira REST API or MCP.
使用Jira REST API或MCP创建和管理Jira问题。
Setup
配置
Option 1: Jira MCP Server
选项1:Jira MCP服务器
Install the Jira MCP server for seamless integration:
bash
npx @anthropic/create-mcp-server jira安装Jira MCP服务器以实现无缝集成:
bash
npx @anthropic/create-mcp-server jiraOption 2: Direct API
选项2:直接调用API
Set environment variables:
bash
export JIRA_BASE_URL="https://yourcompany.atlassian.net"
export JIRA_EMAIL="your-email@company.com"
export JIRA_API_TOKEN="your-api-token"Get your API token: https://id.atlassian.com/manage-profile/security/api-tokens
设置环境变量:
bash
export JIRA_BASE_URL="https://yourcompany.atlassian.net"
export JIRA_EMAIL="your-email@company.com"
export JIRA_API_TOKEN="your-api-token"Creating Issues
创建问题
Basic Issue
基础问题
python
import requests
from requests.auth import HTTPBasicAuth
import os
def create_issue(project_key, summary, description, issue_type="Task"):
url = f"{os.environ['JIRA_BASE_URL']}/rest/api/3/issue"
auth = HTTPBasicAuth(
os.environ['JIRA_EMAIL'],
os.environ['JIRA_API_TOKEN']
)
payload = {
"fields": {
"project": {"key": project_key},
"summary": summary,
"description": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{"type": "text", "text": description}]
}]
},
"issuetype": {"name": issue_type}
}
}
response = requests.post(url, json=payload, auth=auth)
return response.json()python
import requests
from requests.auth import HTTPBasicAuth
import os
def create_issue(project_key, summary, description, issue_type="Task"):
url = f"{os.environ['JIRA_BASE_URL']}/rest/api/3/issue"
auth = HTTPBasicAuth(
os.environ['JIRA_EMAIL'],
os.environ['JIRA_API_TOKEN']
)
payload = {
"fields": {
"project": {"key": project_key},
"summary": summary,
"description": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{"type": "text", "text": description}]
}]
},
"issuetype": {"name": issue_type}
}
}
response = requests.post(url, json=payload, auth=auth)
return response.json()Example
Example
issue = create_issue("PROJ", "Fix login bug", "Users can't login with SSO", "Bug")
print(f"Created: {issue['key']}")
undefinedissue = create_issue("PROJ", "Fix login bug", "Users can't login with SSO", "Bug")
print(f"Created: {issue['key']}")
undefinedWith Labels and Priority
带标签和优先级的问题
python
def create_detailed_issue(project_key, summary, description,
issue_type="Task", priority="Medium",
labels=None, assignee=None):
payload = {
"fields": {
"project": {"key": project_key},
"summary": summary,
"description": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{"type": "text", "text": description}]
}]
},
"issuetype": {"name": issue_type},
"priority": {"name": priority},
}
}
if labels:
payload["fields"]["labels"] = labels
if assignee:
payload["fields"]["assignee"] = {"accountId": assignee}
# ... make requestpython
def create_detailed_issue(project_key, summary, description,
issue_type="Task", priority="Medium",
labels=None, assignee=None):
payload = {
"fields": {
"project": {"key": project_key},
"summary": summary,
"description": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{"type": "text", "text": description}]
}]
},
"issuetype": {"name": issue_type},
"priority": {"name": priority},
}
}
if labels:
payload["fields"]["labels"] = labels
if assignee:
payload["fields"]["assignee"] = {"accountId": assignee}
# ... make requestCommon Issue Types
常见问题类型
| Type | Use For |
|---|---|
| Bug | Something broken |
| Task | Work item |
| Story | User-facing feature |
| Epic | Large initiative |
| Sub-task | Part of larger task |
| 类型 | 适用场景 |
|---|---|
| Bug | 功能故障相关 |
| Task | 工作项 |
| Story | 用户可见功能 |
| Epic | 大型项目 |
| Sub-task | 大型任务的子项 |
Updating Issues
更新问题
Change Status
更改状态
python
def transition_issue(issue_key, transition_name):
# Get available transitions
url = f"{JIRA_BASE_URL}/rest/api/3/issue/{issue_key}/transitions"
transitions = requests.get(url, auth=auth).json()
# Find matching transition
transition_id = None
for t in transitions['transitions']:
if t['name'].lower() == transition_name.lower():
transition_id = t['id']
break
# Execute transition
requests.post(url, json={"transition": {"id": transition_id}}, auth=auth)python
def transition_issue(issue_key, transition_name):
# Get available transitions
url = f"{JIRA_BASE_URL}/rest/api/3/issue/{issue_key}/transitions"
transitions = requests.get(url, auth=auth).json()
# Find matching transition
transition_id = None
for t in transitions['transitions']:
if t['name'].lower() == transition_name.lower():
transition_id = t['id']
break
# Execute transition
requests.post(url, json={"transition": {"id": transition_id}}, auth=auth)Add Comment
添加评论
python
def add_comment(issue_key, comment_text):
url = f"{JIRA_BASE_URL}/rest/api/3/issue/{issue_key}/comment"
payload = {
"body": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{"type": "text", "text": comment_text}]
}]
}
}
requests.post(url, json=payload, auth=auth)python
def add_comment(issue_key, comment_text):
url = f"{JIRA_BASE_URL}/rest/api/3/issue/{issue_key}/comment"
payload = {
"body": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{"type": "text", "text": comment_text}]
}]
}
}
requests.post(url, json=payload, auth=auth)Searching Issues
搜索问题
JQL Queries
JQL查询
python
def search_issues(jql):
url = f"{JIRA_BASE_URL}/rest/api/3/search"
params = {"jql": jql, "maxResults": 50}
response = requests.get(url, params=params, auth=auth)
return response.json()['issues']python
def search_issues(jql):
url = f"{JIRA_BASE_URL}/rest/api/3/search"
params = {"jql": jql, "maxResults": 50}
response = requests.get(url, params=params, auth=auth)
return response.json()['issues']Examples
Examples
my_bugs = search_issues("project = PROJ AND type = Bug AND assignee = currentUser()")
open_items = search_issues("project = PROJ AND status != Done")
recent = search_issues("project = PROJ AND created >= -7d")
undefinedmy_bugs = search_issues("project = PROJ AND type = Bug AND assignee = currentUser()")
open_items = search_issues("project = PROJ AND status != Done")
recent = search_issues("project = PROJ AND created >= -7d")
undefinedQuick Commands
快捷指令
When user says... create this:
| Command | Action |
|---|---|
| "log bug about X" | Bug issue with description |
| "create task for X" | Task issue |
| "what's on my plate" | JQL: assignee = currentUser() AND status != Done |
| "move X to done" | Transition issue to Done |
| "add comment to X" | Add comment to issue |
当用户说... 创建对应的内容:
| 指令 | 操作 |
|---|---|
| "log bug about X" | 创建带有描述的Bug问题 |
| "create task for X" | 创建Task问题 |
| "what's on my plate" | 执行JQL查询:assignee = currentUser() AND status != Done |
| "move X to done" | 将问题状态转换为Done |
| "add comment to X" | 为问题添加评论 |
Best Practices
最佳实践
- Summary: Keep under 80 chars, start with verb (Fix, Add, Update)
- Description: Include steps to reproduce for bugs
- Labels: Use for categorization (frontend, backend, urgent)
- Links: Reference related issues when relevant
- 摘要:控制在80字符以内,以动词开头(修复、添加、更新)
- 描述:Bug问题需包含复现步骤
- 标签:用于分类(前端、后端、紧急)
- 链接:相关问题需添加引用