jira

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Jira CLI

Jira CLI

Command-line tool for managing Jira issues via
af jira
.
一款通过
af jira
命令管理Jira问题的命令行工具。

Setup

配置

Add the following environment variables to your project's
.env
file:
将以下环境变量添加到项目的
.env
文件中:

Quick Reference

快速参考

Run
af jira --help
for all options.
运行
af jira --help
查看所有可用选项。

Read Operations

读取操作

  • af jira get <issue-key>
    — Get issue details
  • af jira list <project> [--limit N]
    — List project issues
  • af jira search "<jql>"
    — Search with JQL
  • af jira projects
    — List projects
  • af jira types <project>
    — List issue types
  • af jira transitions <issue-key>
    — List available transitions
  • af jira comment <issue-key>
    — List comments
  • af jira get <issue-key>
    — 获取问题详情
  • af jira list <project> [--limit N]
    — 列出项目中的问题
  • af jira search "<jql>"
    — 使用JQL进行搜索
  • af jira projects
    — 列出所有项目
  • af jira types <project>
    — 列出项目的问题类型
  • af jira transitions <issue-key>
    — 列出可用的状态流转
  • af jira comment <issue-key>
    — 列出问题评论

Write Operations

写入操作

  • af jira create --project <key> --type <type> --summary "<text>" [--description "<text>"] [--priority <name>] [--labels a,b,c] [--parent <key>]
  • af jira update <issue-key> [--summary "<text>"] [--description "<text>"] [--priority <name>] [--labels a,b,c]
  • af jira transition <issue-key> --to "<status>"
  • af jira assign <issue-key> --to <email>
    (use
    --to none
    to unassign)
  • af jira comment <issue-key> --add "<text>"
  • af jira attach <issue-key> <file>
    — Attach a file (images, PDFs, etc.)
  • af jira delete <issue-key>
  • af jira create --project <key> --type <type> --summary "<text>" [--description "<text>"] [--priority <name>] [--labels a,b,c] [--parent <key>]
  • af jira update <issue-key> [--summary "<text>"] [--description "<text>"] [--priority <name>] [--labels a,b,c]
  • af jira transition <issue-key> --to "<status>"
  • af jira assign <issue-key> --to <email>
    (使用
    --to none
    取消分配)
  • af jira comment <issue-key> --add "<text>"
  • af jira attach <issue-key> <file>
    — 上传附件(图片、PDF等)
  • af jira delete <issue-key>

Output Formats

输出格式

  • Default: Markdown
  • JSON: Add
    --json
    flag
  • 默认:Markdown
  • JSON格式:添加
    --json
    参数

Common Workflows

常见工作流

View my assigned issues

查看我负责的问题

bash
af jira search "assignee = currentUser() AND status != Done ORDER BY priority DESC"
bash
af jira search "assignee = currentUser() AND status != Done ORDER BY priority DESC"

Start working on an issue

开始处理某个问题

bash
af jira get PROJ-123
af jira transition PROJ-123 --to "In Progress"
af jira comment PROJ-123 --add "Starting work"
bash
af jira get PROJ-123
af jira transition PROJ-123 --to "In Progress"
af jira comment PROJ-123 --add "Starting work"

Complete an issue

完成某个问题

bash
af jira comment PROJ-123 --add "Done"
af jira transition PROJ-123 --to "Done"
bash
af jira comment PROJ-123 --add "Done"
af jira transition PROJ-123 --to "Done"

Create a bug with details

创建包含详细信息的Bug

bash
af jira create --project PROJ --type Bug --summary "Login fails on Safari" \
  --description "Users cannot log in using Safari 17. Error: 'Invalid session'" \
  --priority High --labels safari,auth,urgent
bash
af jira create --project PROJ --type Bug --summary "Login fails on Safari" \
  --description "Users cannot log in using Safari 17. Error: 'Invalid session'" \
  --priority High --labels safari,auth,urgent

Create a subtask

创建子任务

bash
af jira create --project PROJ --type Sub-task --summary "Write unit tests" \
  --parent PROJ-123
bash
af jira create --project PROJ --type Sub-task --summary "Write unit tests" \
  --parent PROJ-123

Attach files to an issue

为问题添加附件

bash
undefined
bash
undefined

Attach a screenshot

上传截图

af jira attach PROJ-123 ./screenshot.png
af jira attach PROJ-123 ./screenshot.png

Attach multiple files

上传多个文件

for f in ./audit/*.png; do af jira attach PROJ-123 "$f" done
undefined
for f in ./audit/*.png; do af jira attach PROJ-123 "$f" done
undefined

Search examples

搜索示例

bash
undefined
bash
undefined

My open issues

我的未完成问题

af jira search "assignee = currentUser() AND status != Done"
af jira search "assignee = currentUser() AND status != Done"

Recent bugs in project

项目中近期的Bug

af jira search "project = PROJ AND type = Bug ORDER BY created DESC" --limit 10
af jira search "project = PROJ AND type = Bug ORDER BY created DESC" --limit 10

Unassigned issues

未分配的问题

af jira search "project = PROJ AND assignee IS EMPTY"
af jira search "project = PROJ AND assignee IS EMPTY"

Issues updated this week

本周更新的问题

af jira search "project = PROJ AND updated >= -7d"
af jira search "project = PROJ AND updated >= -7d"

High priority blockers

高优先级阻塞问题

af jira search "priority = Highest AND status != Done"
undefined
af jira search "priority = Highest AND status != Done"
undefined

Tips

提示

  • Discover valid values first: Run
    af jira transitions <key>
    before transitioning,
    af jira types <project>
    before creating
  • Use
    --json
    for scripting
    : Pipe output to
    jq
    for automation
  • Quote JQL queries: Always wrap JQL in double quotes to handle spaces
  • 先确认有效值:在执行状态流转前先运行
    af jira transitions <key>
    ,在创建问题前先运行
    af jira types <project>
  • 使用
    --json
    进行脚本开发
    :可将输出通过管道传递给
    jq
    实现自动化
  • JQL查询需加引号:始终用双引号包裹JQL查询语句以处理空格

Error Handling

错误处理

  • Errors print to stderr
  • With
    --json
    :
    {"error": "message"}
  • Exit codes:
    0
    success,
    1
    error
  • 错误信息会输出到stderr
  • 使用
    --json
    参数时:
    {"error": "message"}
  • 退出码:
    0
    表示成功,
    1
    表示错误