git-jira-fast-ticket
v2.3.0
Published
Streamline your workflow with this CLI tool that creates Jira tickets and automatically switches to a new Git branch named after the ticket. Perfect for developers using Git and Jira for project management on Unix-like systems.
Maintainers
Readme
git-jira-fast-ticket
Create a Jira work item and immediately switch to a Git branch named after it.
$ git-jira-fast-ticket PAY "Fix the checkout redirect"
Jira ticket created: PAY-412 - https://your-domain.atlassian.net/browse/PAY-412
Switched to a new branch 'PAY-412-Fix-the-checkout-redirect'Quickstart
Install it:
npm install -g git-jira-fast-ticketConfigure it once. The wizard asks for your Jira URL, your email and an API token, and where to keep the token:
git-jira-fast-ticket setupCreate a ticket from inside any Git repository:
git-jira-fast-ticket PAY "Fix the checkout redirect"
Run git-jira-fast-ticket --help at any time to see what is configured and where each value came from.
Requirements
- Node.js 18 or newer. Node is the only runtime this tool needs; there is no Bash,
curlorjqinvolvement. - Git 2.x. The tool creates the ticket and then creates the branch.
Creating a Jira API token
- Open https://id.atlassian.com/manage-profile/security/api-tokens (Atlassian profile → Security → API tokens).
- Choose Create API token, give it a name, and copy the value.
- Paste it when the setup wizard asks for the Personal Access Token. It is read without echoing and never printed.
The email must be the address you sign in to Jira with; the URL is your site root, for example https://your-domain.atlassian.net.
Configuration
Settings live in Git config, under the jira-fast-ticket section. That means there is no config file to create, and both scopes come for free: git config --global applies everywhere, git config --local applies to one repository and takes precedence.
| Setting | Environment variable | Default | Purpose |
| --- | --- | --- | --- |
| jira-fast-ticket.url | JIRA_URL | — | Jira site root, for example https://your-domain.atlassian.net |
| jira-fast-ticket.email | JIRA_EMAIL | — | The email you sign in to Jira with |
| jira-fast-ticket.token | JIRA_PAT | — | A Jira API token |
| jira-fast-ticket.issueType | JIRA_ISSUE_TYPE | Task | Work item type to create |
Values are resolved per setting, first match wins:
- A non-empty environment variable.
- The repository-local Git config.
- The global Git config.
- The default, where the setting has one.
To set them by hand:
git config --global jira-fast-ticket.url https://your-domain.atlassian.net
git config --global jira-fast-ticket.email [email protected]
git config --local jira-fast-ticket.token <your-api-token>The wizard writes the URL and email globally. It asks where the token should go:
- This repository (the default) writes it to
.git/config, which cannot be committed, so the token cannot leak into the repository. - All repositories writes it to the shared Git config, which is convenient but also the file people paste into public dotfiles repositories.
A repository-scoped token also lets you point the URL at a second Jira site in one repository without affecting the others.
Usage
git-jira-fast-ticket <PROJECT_KEY> <TITLE> [DESCRIPTION] [OPTIONS]Because Git resolves git-<name> from PATH, the subcommand form works as well:
git jira-fast-ticket PAY "Fix the checkout redirect"PROJECT_KEY: the Jira project key, for examplePAY.TITLE: the work item summary.DESCRIPTION: optional; a plain-text description. Defaults to the title.
Options:
| Option | Effect |
| --- | --- |
| -x, --no-checkout | Create the ticket but only print the branch command; do not create or switch branches |
| --configure | Run the setup wizard, same as git-jira-fast-ticket setup |
| -v, --version | Print the version |
| -h, --help | Print help and the configuration status |
| -- | Treat everything after it as positional arguments |
The created work item is printed, and the branch is created and checked out. The branch name is <KEY>-<title> with every run of characters outside A-Za-z0-9 collapsed to a single dash and any leading or trailing dash removed, so Fix the checkout redirect becomes PAY-412-Fix-the-checkout-redirect.
Troubleshooting
The tool prints the reason Jira gave, plus a hint that names the setting to check.
| Message | Fix |
| --- | --- |
| Missing required configuration: JIRA_URL, ... | Run git-jira-fast-ticket setup, or set the missing keys as shown in the message |
| 401 / 403 | The email or token is wrong or expired. Check JIRA_EMAIL and JIRA_PAT, or create a new API token |
| 404 | JIRA_URL is wrong, or the project key does not exist |
| 400, or an error naming issuetype | The project does not use the configured work item type. Set it: git config --global jira-fast-ticket.issueType Story |
| 429 | Jira is rate limiting. Retry in a moment |
| 5xx | A Jira-side error. Retry shortly |
| A network error | Check that JIRA_URL is reachable and that the machine is online |
Development
git clone https://github.com/tiriana/git-jira-fast-ticket.git
cd git-jira-fast-ticket
npm ci
npm testThe suite uses the built-in node:test runner and needs no network access or real credentials: the end-to-end tests run the real entry point inside temporary repositories against a local Jira stub.
