Skip to content

CLI tool interacting with JIRA REST api

Notifications You must be signed in to change notification settings

PieterT2000/jira-cli

Repository files navigation

Jira CLI

Setup

Install (Unix & Windows compatible)

npm i -g @pietert/jira-api

Configure

Now run

jira setup

You will be asked for:

  • endpoint: this should be in the form of https://company_name.atlassian.net
  • username: your email that you use to login to Jira
  • apiToken: you can create your token here.
  • boardId: this is the id of the sprint board. You can find it by going to the backlog or sprint board. The integer after /boards/ is the boardId.

Commands

Worklogs (i.e. timetracking)

To start the timer. If no ISSUE_KEYis provided and you're currently in a git branch, the name of that branch will be used as issue key. Otherwise an error will be thrown. This is what issue keys look like

jira start [ISSUE_KEY]

To stop the timer and save the worklog. If you don't provide the issueKey, your current git branch name will be used. (very handy if git branches are linked to Jira issues). Otherwise, an error will be thrown.

jira stop [COMMENT] [ISSUE_KEY]

Logging recurring activities.

jira log ACTIVITY

You can define recurring activities in the cli-config.js file. For example:

export default {
  standup: {
    issueKey: "PROJECTNAME-XXXX",
    comment: "Standup",
    timeSpent: 900,
    startTime: "08:30",
  },
};

Note that timeSpent must be in seconds. startTime can be in any time format. (e.g. 12, 3 pm, 15:49, 11:49:34 a.m., etc) After defining standup as a recurring activity, you can run jira log standup. Look for more examples in cli-config.js. TIP: use cron-jobs to automate the logging of recurring events.

List issues

To get a table displaying the current issues in the sprint, run

jira issue|is list|ls [STATUS_CATEGORY]

Lookup issue information

To view information about a specific Jira issue

jira info|i [ISSUE_KEY]

Adding comments

jira comment|cm add ISSUE_KEY COMMENT [MENTION]

You can also include a mention (first name of person you want to mention). This will add a mention block at the front of your comment in Jira. Note: the COMMENT argument must be a quoted string.

Help

Whenever stuck or when you trying to find info or aliases for a command, run

jira [COMMAND ...] - h