From 623429dd0aec1aa84e626e81f24e66565a891a07 Mon Sep 17 00:00:00 2001 From: Johannes Larsson Date: Mon, 16 Jun 2025 11:06:03 +0200 Subject: [PATCH 1/4] Add cookie support Signed-off-by: Johannes Larsson --- README.md | 19 ++++++++++++++++++- pkg/jira/client.go | 2 ++ pkg/jira/types.go | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 309a09b3..7774d0a2 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,23 @@ Follow the [installation guide](https://github.com/ankitpokhrel/jira-cli/wiki/In 2. Run `jira init`, select installation type as `Cloud`, and provide required details to generate a config file required for the tool. +#### Cloud server without personal access token +Some tenants has disabled the ability to create personal Jira API tokens. The alternative then is to use the browser session cookie/token `tenant.session.token`. These will last for a day before they expire. + +1. Configure your cli by creating the `~/.config/.jira/.config.yml` +``` +installation: cloud +server: https://.atlassian.net +auth_type: cookie +``` + +2. Login to Jira with your browser. View the developer extension and find the cookie value of `tenant.session.token`. Then set then environment variable `JIRA_API_TOKEN` as that value. + +``` +export JIRA_API_TOKEN=ey.. +``` + + #### On-premise installation 1. Export required environment variables: @@ -672,7 +689,7 @@ $ jira sprint add SPRINT_ID ISSUE-1 ISSUE-2 ### Releases -Interact with releases (project versions). +Interact with releases (project versions). Ensure the [feature is enabled](https://support.atlassian.com/jira-software-cloud/docs/enable-releases-and-versions/) on your instance. #### List diff --git a/pkg/jira/client.go b/pkg/jira/client.go index c6435dbc..5c16ed39 100644 --- a/pkg/jira/client.go +++ b/pkg/jira/client.go @@ -281,6 +281,8 @@ func (c *Client) request(ctx context.Context, method, endpoint string, body []by } case string(AuthTypeBearer): req.Header.Add("Authorization", "Bearer "+c.token) + case string(AuthTypeCookie): + req.Header.Add("Cookie", "tenant.session.token="+c.token) case string(AuthTypeBasic): req.SetBasicAuth(c.login, c.token) } diff --git a/pkg/jira/types.go b/pkg/jira/types.go index e1c17719..bea00ea6 100644 --- a/pkg/jira/types.go +++ b/pkg/jira/types.go @@ -7,6 +7,8 @@ import ( const ( // AuthTypeBasic is a basic auth. AuthTypeBasic AuthType = "basic" + // AuthTypeBasic is a cookie auth. + AuthTypeCookie AuthType = "cookie" // AuthTypeBearer is a bearer auth. AuthTypeBearer AuthType = "bearer" // AuthTypeMTLS is a mTLS auth. From 5c69525278cfff7c03c62de61c7d599df8eaa6d0 Mon Sep 17 00:00:00 2001 From: Johannes Larsson Date: Thu, 2 Oct 2025 09:11:25 +0200 Subject: [PATCH 2/4] docs: Updated bootstrap instructions --- README.md | 92 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 628aa468..c058f6f7 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ features like issue creation, cloning, linking, ticket transition, and much more > This tool is heavily inspired by the [GitHub CLI](https://github.com/cli/cli) ## Supported platforms +> > [!NOTE] > Some features might work slightly differently in cloud installation versus on-premise installation due to the nature of the data. Yet, we've attempted to make the experience as similar as possible. @@ -69,6 +70,7 @@ nature of the data. Yet, we've attempted to make the experience as similar as po | **Jira** | Jira CloudJira Server | ## Installation + `jira-cli` is available as a downloadable packaged binary for Linux, macOS, and Windows from the [releases page](https://github.com/ankitpokhrel/jira-cli/releases). You can use Docker to quickly try out `jira-cli`. @@ -94,22 +96,22 @@ Follow the [installation guide](https://github.com/ankitpokhrel/jira-cli/wiki/In 2. Run `jira init`, select installation type as `Cloud`, and provide required details to generate a config file required for the tool. -#### Cloud server without personal access token -Some tenants has disabled the ability to create personal Jira API tokens. The alternative then is to use the browser session cookie/token `tenant.session.token`. These will last for a day before they expire. +#### Cloud server without personal access token / OAuth enabled -1. Configure your cli by creating the `~/.config/.jira/.config.yml` -``` -installation: cloud -server: https://.atlassian.net -auth_type: cookie -``` +Some tenants have disabled the ability to create personal Jira API tokens. In these cases, the alternative is to use the browser session cookie/token tenant.session.token. Note that these tokens expire after one day. -2. Login to Jira with your browser. View the developer extension and find the cookie value of `tenant.session.token`. Then set then environment variable `JIRA_API_TOKEN` as that value. +1. Log in to Jira with your browser. Open the developer tools and find the cookie value for tenant.session.token. Then set the environment variable `JIRA_API_TOKEN` to that value. -``` +```sh export JIRA_API_TOKEN=ey.. ``` +2. Bootstrap your cli + +```sh + +jira init --installation cloud --server https://.atlassian.net --auth-type cookie --project ABC +``` #### On-premise installation @@ -139,11 +141,12 @@ See [FAQs](https://github.com/ankitpokhrel/jira-cli/discussions/categories/faqs) The tool supports `basic`, `bearer` (Personal Access Token), and `mtls` (Client Certificates) authentication types. Basic auth is used by default. -* If you want to use PAT, you need to set `JIRA_AUTH_TYPE` as `bearer`. -* If you want to use `mtls` run `jira init`. Select installation type `Local`, and then select authentication type as `mtls`. - * In case `JIRA_API_TOKEN` variable is set it will be used together with `mtls`. +- If you want to use PAT, you need to set `JIRA_AUTH_TYPE` as `bearer`. +- If you want to use `mtls` run `jira init`. Select installation type `Local`, and then select authentication type as `mtls`. + - In case `JIRA_API_TOKEN` variable is set it will be used together with `mtls`. #### Shell completion + Check `jira completion --help` for more info on setting up a bash/zsh shell completion. #### Multiple projects @@ -158,15 +161,19 @@ $ jira issue list -c ./local_jira_config.yaml ``` ## Usage + The tool currently comes with an issue, epic, and sprint explorer. The flags are [POSIX-compliant](https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html). You can combine available flags in any order to create a unique query. For example, the command below will give you high priority issues created this month with status `To Do` that are assigned to you and has the label `backend`. + ```sh jira issue list -yHigh -s"To Do" --created month -lbackend -a$(jira me) ``` ### Navigation + The lists are displayed in an interactive UI by default. + - Use arrow keys or `j, k, h, l` characters to navigate through the list. - Use `g` and `G` to quickly navigate to the top and bottom respectively. - Use `CTRL + f` to scroll through a page downwards direction. @@ -182,6 +189,7 @@ The lists are displayed in an interactive UI by default. - Press `?` to open the help window. ### Resources + - [FAQs](https://github.com/ankitpokhrel/jira-cli/discussions/categories/faqs) - [Introduction and Motivation](https://medium.com/@ankitpokhrel/introducing-jira-cli-the-missing-command-line-tool-for-atlassian-jira-fe44982cc1de) - [Getting Started with JiraCLI](https://www.mslinn.com/blog/2022/08/12/jiracli.html) @@ -190,10 +198,13 @@ The lists are displayed in an interactive UI by default. > Like this tool? Checkout [similar tool for Shopify!](https://github.com/ankitpokhrel/shopctl) ## Commands + ### Issue + Issues are displayed in an interactive table view by default. You can output the results in a plain view using the `--plain` flag. #### List + The `list` command lets you search and navigate the issues. The issues are sorted by `created` field in descending order by default. ```sh @@ -231,6 +242,7 @@ Check some more examples/use-cases below. ```sh jira issue list -w ``` +
List issues assigned to me @@ -238,6 +250,7 @@ jira issue list -w ```sh jira issue list -a$(jira me) ``` +
List issues assigned to a user and are reported by another user @@ -245,6 +258,7 @@ jira issue list -a$(jira me) ```sh jira issue list -a"User A" -r"User B" ``` +
List issues assigned to me, is of high priority and is open @@ -252,6 +266,7 @@ jira issue list -a"User A" -r"User B" ```sh jira issue list -a$(jira me) -yHigh -sopen ``` +
List issues assigned to no one and are created this week @@ -259,6 +274,7 @@ jira issue list -a$(jira me) -yHigh -sopen ```sh jira issue list -ax --created week ``` +
List issues with resolution won't do @@ -266,6 +282,7 @@ jira issue list -ax --created week ```sh jira issue list -R"Won't do" ``` +
List issues whose status is not done and is created before 6 months and is assigned to someone @@ -274,6 +291,7 @@ jira issue list -R"Won't do" # Tilde (~) acts as a not operator jira issue list -s~Done --created-before -24w -a~x ``` +
List issues created within an hour and updated in the last 30 minutes :stopwatch: @@ -281,6 +299,7 @@ jira issue list -s~Done --created-before -24w -a~x ```sh jira issue list --created -1h --updated -30m ``` +
Give me issues that are of high priority, are in progress, were created this month, and have given labels :fire: @@ -288,6 +307,7 @@ jira issue list --created -1h --updated -30m ```sh jira issue list -yHigh -s"In Progress" --created month -lbackend -l"high-prio" ``` +
Wait, what was that ticket I opened earlier today? :tired_face: @@ -295,6 +315,7 @@ jira issue list -yHigh -s"In Progress" --created month -lbackend -l"high-prio" ```sh jira issue list --history ``` +
What was the first issue I ever reported on the current board? :thinking: @@ -302,6 +323,7 @@ jira issue list -yHigh -s"In Progress" --created month -lbackend -l"high-prio" ```sh jira issue list -r$(jira me) --reverse ``` +
What was the first bug I ever fixed in the current board? :beetle: @@ -309,6 +331,7 @@ jira issue list -r$(jira me) --reverse ```sh jira issue list -a$(jira me) -tBug sDone -rFixed --reverse ``` +
What issues did I report this week? :man_shrugging: @@ -316,6 +339,7 @@ jira issue list -a$(jira me) -tBug sDone -rFixed --reverse ```sh jira issue list -r$(jira me) --created week ``` +
Am I watching any tickets in project XYZ? :monocle_face: @@ -323,9 +347,11 @@ jira issue list -r$(jira me) --created week ```sh jira issue list -w -pXYZ ``` +
#### Create + The `create` command lets you create an issue. ```sh @@ -367,6 +393,7 @@ $ echo "Description from stdin" | jira issue create -s"Summary" -tTask > The preview above shows markdown template passed in Jira CLI and how it is rendered in the Jira UI. #### Edit + The `edit` command lets you edit an issue. ```sh @@ -386,6 +413,7 @@ $ jira issue edit ISSUE-1 --label -p2 --label p1 --component -FE --component BE ``` #### Assign + The `assign` command lets you assign a user to an issue. ```sh @@ -411,6 +439,7 @@ $ jira issue assign ISSUE-1 x ![Assign issue to a user](.github/assets/assign.gif) #### Move/Transition + The `move` command lets you transition an issue from one state to another. ```sh @@ -437,13 +466,14 @@ $ jira issue move ISSUE-1 Done -RFixed -a$(jira me) To transition the selected issue from the TUI, press `m`. #### View + The `view` command lets you see issue details in a terminal. Atlassian document is roughly converted to a markdown and is nicely displayed in the terminal. -The command uses `less` as a pager by default. To set your own pager, see https://github.com/ankitpokhrel/jira-cli/discussions/569. +The command uses `less` as a pager by default. To set your own pager, see . ```sh -$ jira issue view ISSUE-1 +jira issue view ISSUE-1 ``` ![View an issue](.github/assets/view.gif) @@ -457,6 +487,7 @@ $ jira issue view ISSUE-1 --comments 5 ``` #### Link + The `link` command lets you link two issues. ```sh @@ -468,6 +499,7 @@ $ jira issue link ISSUE-1 ISSUE-2 Blocks ``` ##### Remote + The `remote` command lets you add a remote web link to an issue. ```sh @@ -479,6 +511,7 @@ $ jira issue link remote ISSUE-1 https://example.com "Example text" ``` #### Unlink + The `unlink` command lets you unlink two linked issues. ```sh @@ -490,6 +523,7 @@ $ jira issue unlink ISSUE-1 ISSUE-2 ``` #### Clone + The `clone` command lets you clone an issue. You can update fields like summary, priority, assignee, labels, and components when cloning the issue. The command also allows you to replace a part of the string (case-sensitive) in summary and description using `--replace/-H` option. @@ -506,6 +540,7 @@ $ jira issue clone ISSUE-1 -H"find me:replace with me" ``` #### Delete + The `delete` command lets you delete an issue. ```sh @@ -520,9 +555,11 @@ $ jira issue delete ISSUE-1 --cascade ``` #### Comment + The `comment` command provides a list of sub-commands to manage issue comments. ##### Add + The `add` command lets you add a comment to an issue. The command supports both [Github-flavored](https://github.github.com/gfm/) and [Jira-flavored](https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all) markdown for writing comment. You can load pre-defined templates using `--template` flag. @@ -550,6 +587,7 @@ $ echo "Comment from stdin" | jira issue comment add ISSUE-1 > [!NOTE] > For the comment body, the positional argument always takes precedence over the `--template` flag if both of them are passed. In the example below, the body will be picked from positional argument instead of the template. + ```sh jira issue comment add ISSUE-42 "comment body positional" --template - <<'EOF' comment body template @@ -557,9 +595,11 @@ EOF ``` #### Worklog + The `worklog` command provides a list of sub-commands to manage issue worklog (timelog). ##### Add + The `add` command lets you add a worklog to an issue. The command supports markdown for worklog comments. ```sh @@ -574,12 +614,14 @@ $ jira issue worklog add ISSUE-1 "10m" --comment "This is a comment" --no-input ``` ### Epic + Epics are displayed in an explorer view by default. You can output the results in a table view using the `--table` flag. When viewing epic issues, you can use all filters available for the issue command. See [usage](#navigation) to learn more about UI interaction. #### List + You can use all flags supported by `issue list` command here except for the issue type. ```sh @@ -606,6 +648,7 @@ $ jira epic list KEY-1 --order-by rank --reverse ``` #### Create + Creating an epic is the same as creating the issue except you also need to provide an epic name. ```sh @@ -617,6 +660,7 @@ $ jira epic create -n"Epic epic" -s"Everything" -yHigh -lbug -lurgent -b"Epic de ``` #### Add + The `add` command allows you to add issues to the epic. You can add up to 50 issues to the epic at once. ```sh @@ -628,6 +672,7 @@ $ jira epic add EPIC-KEY ISSUE-1 ISSUE-2 ``` #### Remove + The `remove` command allows you to remove issues from the epic. You can remove up to 50 issues from the epic at once. ```sh @@ -639,12 +684,14 @@ $ jira epic remove ISSUE-1 ISSUE-2 ``` ### Sprint + Sprints are displayed in an explorer view by default. You can output the results in a table view using the `--table` flag. When viewing sprint issues, you can use all filters available for the issue command. The tool only shows 25 recent sprints. See [usage](#navigation) to learn more about UI interaction. #### List + You can use all flags supported by `issue list` command to filter issues in the sprint. ```sh @@ -681,6 +728,7 @@ $ jira sprint list SPRINT_ID --order-by rank --reverse ``` #### Add + The `add` command allows you to add issues to the sprint. You can add up to 50 issues to the sprint at once. ```sh @@ -714,6 +762,7 @@ $ jira release list --project KEY ```sh jira open ``` +
Navigate to the issue @@ -721,6 +770,7 @@ jira open ```sh jira open KEY-1 ``` +
List all projects you have access to @@ -728,6 +778,7 @@ jira open KEY-1 ```sh jira project list ``` +
List all boards in a project @@ -735,9 +786,11 @@ jira project list ```sh jira board list ``` +
## Scripts + Often times, you may want to use the output of the command to do something cool. However, the default interactive UI might not allow you to do that. The tool comes with the `--plain` flag that displays results in a simple layout that can then be manipulated from the shell script. @@ -763,6 +816,7 @@ Day #02: 10 Day #03: 21 ... ``` +
Number of tickets per sprint @@ -784,6 +838,7 @@ Sprint 2: 40 Sprint 1: 30 ... ``` +
Number of unique assignee per sprint @@ -804,6 +859,7 @@ Sprint 3: 5 Sprint 2: 4 Sprint 1: 3 ``` +
## Known Issues @@ -822,28 +878,34 @@ Please [open a discussion](https://github.com/ankitpokhrel/jira-cli/discussions/ - Rest of the features will be picked based on the [number of votes](https://github.com/ankitpokhrel/jira-cli/discussions/categories/ideas) on the particular feature. ## Development + 1. Clone the repo. + ```sh git clone git@github.com:ankitpokhrel/jira-cli.git ``` 2. Optional: If you want to run a Jira instance locally, you can use the following make recipe. The trial license key can be generated from the "Licenses" section in the [atlassian admin](https://my.atlassian.com). + ```sh make jira.server ``` 3. Make changes, build the binary, and test your changes. + ```sh make deps install ``` 4. Run CI steps locally before submitting a PR. + ```sh make ci ``` ## Support the project + Your suggestions and feedbacks are highly appreciated. Please feel free to [start a discussion](https://github.com/ankitpokhrel/jira-cli/discussions) or [create an issue](https://github.com/ankitpokhrel/jira-cli/issues/new) to share your experience with the tool or to From 563112d32fd68d849b6df2f311f864398cef689d Mon Sep 17 00:00:00 2001 From: Johannes Larsson Date: Thu, 2 Oct 2025 09:35:20 +0200 Subject: [PATCH 3/4] docs: disabled autofmt --- README.md | 76 +++++-------------------------------------------------- 1 file changed, 7 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index c058f6f7..2b624951 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,6 @@ features like issue creation, cloning, linking, ticket transition, and much more > This tool is heavily inspired by the [GitHub CLI](https://github.com/cli/cli) ## Supported platforms -> > [!NOTE] > Some features might work slightly differently in cloud installation versus on-premise installation due to the nature of the data. Yet, we've attempted to make the experience as similar as possible. @@ -70,7 +69,6 @@ nature of the data. Yet, we've attempted to make the experience as similar as po | **Jira** | Jira CloudJira Server | ## Installation - `jira-cli` is available as a downloadable packaged binary for Linux, macOS, and Windows from the [releases page](https://github.com/ankitpokhrel/jira-cli/releases). You can use Docker to quickly try out `jira-cli`. @@ -98,7 +96,7 @@ Follow the [installation guide](https://github.com/ankitpokhrel/jira-cli/wiki/In #### Cloud server without personal access token / OAuth enabled -Some tenants have disabled the ability to create personal Jira API tokens. In these cases, the alternative is to use the browser session cookie/token tenant.session.token. Note that these tokens expire after one day. +Some tenants have disabled the ability to create personal Jira API tokens. In these cases, the alternative is to use the browser session cookie/token `tenant.session.token`. Note that these tokens expire after one day. 1. Log in to Jira with your browser. Open the developer tools and find the cookie value for tenant.session.token. Then set the environment variable `JIRA_API_TOKEN` to that value. @@ -141,12 +139,11 @@ See [FAQs](https://github.com/ankitpokhrel/jira-cli/discussions/categories/faqs) The tool supports `basic`, `bearer` (Personal Access Token), and `mtls` (Client Certificates) authentication types. Basic auth is used by default. -- If you want to use PAT, you need to set `JIRA_AUTH_TYPE` as `bearer`. -- If you want to use `mtls` run `jira init`. Select installation type `Local`, and then select authentication type as `mtls`. - - In case `JIRA_API_TOKEN` variable is set it will be used together with `mtls`. +* If you want to use PAT, you need to set `JIRA_AUTH_TYPE` as `bearer`. +* If you want to use `mtls` run `jira init`. Select installation type `Local`, and then select authentication type as `mtls`. + * In case `JIRA_API_TOKEN` variable is set it will be used together with `mtls`. #### Shell completion - Check `jira completion --help` for more info on setting up a bash/zsh shell completion. #### Multiple projects @@ -161,19 +158,15 @@ $ jira issue list -c ./local_jira_config.yaml ``` ## Usage - The tool currently comes with an issue, epic, and sprint explorer. The flags are [POSIX-compliant](https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html). You can combine available flags in any order to create a unique query. For example, the command below will give you high priority issues created this month with status `To Do` that are assigned to you and has the label `backend`. - ```sh jira issue list -yHigh -s"To Do" --created month -lbackend -a$(jira me) ``` ### Navigation - The lists are displayed in an interactive UI by default. - - Use arrow keys or `j, k, h, l` characters to navigate through the list. - Use `g` and `G` to quickly navigate to the top and bottom respectively. - Use `CTRL + f` to scroll through a page downwards direction. @@ -189,7 +182,6 @@ The lists are displayed in an interactive UI by default. - Press `?` to open the help window. ### Resources - - [FAQs](https://github.com/ankitpokhrel/jira-cli/discussions/categories/faqs) - [Introduction and Motivation](https://medium.com/@ankitpokhrel/introducing-jira-cli-the-missing-command-line-tool-for-atlassian-jira-fe44982cc1de) - [Getting Started with JiraCLI](https://www.mslinn.com/blog/2022/08/12/jiracli.html) @@ -198,13 +190,10 @@ The lists are displayed in an interactive UI by default. > Like this tool? Checkout [similar tool for Shopify!](https://github.com/ankitpokhrel/shopctl) ## Commands - ### Issue - Issues are displayed in an interactive table view by default. You can output the results in a plain view using the `--plain` flag. #### List - The `list` command lets you search and navigate the issues. The issues are sorted by `created` field in descending order by default. ```sh @@ -242,7 +231,6 @@ Check some more examples/use-cases below. ```sh jira issue list -w ``` -
List issues assigned to me @@ -250,7 +238,6 @@ jira issue list -w ```sh jira issue list -a$(jira me) ``` -
List issues assigned to a user and are reported by another user @@ -258,7 +245,6 @@ jira issue list -a$(jira me) ```sh jira issue list -a"User A" -r"User B" ``` -
List issues assigned to me, is of high priority and is open @@ -266,7 +252,6 @@ jira issue list -a"User A" -r"User B" ```sh jira issue list -a$(jira me) -yHigh -sopen ``` -
List issues assigned to no one and are created this week @@ -274,7 +259,6 @@ jira issue list -a$(jira me) -yHigh -sopen ```sh jira issue list -ax --created week ``` -
List issues with resolution won't do @@ -282,7 +266,6 @@ jira issue list -ax --created week ```sh jira issue list -R"Won't do" ``` -
List issues whose status is not done and is created before 6 months and is assigned to someone @@ -291,7 +274,6 @@ jira issue list -R"Won't do" # Tilde (~) acts as a not operator jira issue list -s~Done --created-before -24w -a~x ``` -
List issues created within an hour and updated in the last 30 minutes :stopwatch: @@ -299,7 +281,6 @@ jira issue list -s~Done --created-before -24w -a~x ```sh jira issue list --created -1h --updated -30m ``` -
Give me issues that are of high priority, are in progress, were created this month, and have given labels :fire: @@ -307,7 +288,6 @@ jira issue list --created -1h --updated -30m ```sh jira issue list -yHigh -s"In Progress" --created month -lbackend -l"high-prio" ``` -
Wait, what was that ticket I opened earlier today? :tired_face: @@ -315,7 +295,6 @@ jira issue list -yHigh -s"In Progress" --created month -lbackend -l"high-prio" ```sh jira issue list --history ``` -
What was the first issue I ever reported on the current board? :thinking: @@ -323,7 +302,6 @@ jira issue list -yHigh -s"In Progress" --created month -lbackend -l"high-prio" ```sh jira issue list -r$(jira me) --reverse ``` -
What was the first bug I ever fixed in the current board? :beetle: @@ -331,7 +309,6 @@ jira issue list -r$(jira me) --reverse ```sh jira issue list -a$(jira me) -tBug sDone -rFixed --reverse ``` -
What issues did I report this week? :man_shrugging: @@ -339,7 +316,6 @@ jira issue list -a$(jira me) -tBug sDone -rFixed --reverse ```sh jira issue list -r$(jira me) --created week ``` -
Am I watching any tickets in project XYZ? :monocle_face: @@ -347,11 +323,9 @@ jira issue list -r$(jira me) --created week ```sh jira issue list -w -pXYZ ``` -
#### Create - The `create` command lets you create an issue. ```sh @@ -393,7 +367,6 @@ $ echo "Description from stdin" | jira issue create -s"Summary" -tTask > The preview above shows markdown template passed in Jira CLI and how it is rendered in the Jira UI. #### Edit - The `edit` command lets you edit an issue. ```sh @@ -413,7 +386,6 @@ $ jira issue edit ISSUE-1 --label -p2 --label p1 --component -FE --component BE ``` #### Assign - The `assign` command lets you assign a user to an issue. ```sh @@ -439,7 +411,6 @@ $ jira issue assign ISSUE-1 x ![Assign issue to a user](.github/assets/assign.gif) #### Move/Transition - The `move` command lets you transition an issue from one state to another. ```sh @@ -466,14 +437,13 @@ $ jira issue move ISSUE-1 Done -RFixed -a$(jira me) To transition the selected issue from the TUI, press `m`. #### View - The `view` command lets you see issue details in a terminal. Atlassian document is roughly converted to a markdown and is nicely displayed in the terminal. -The command uses `less` as a pager by default. To set your own pager, see . +The command uses `less` as a pager by default. To set your own pager, see https://github.com/ankitpokhrel/jira-cli/discussions/569. ```sh -jira issue view ISSUE-1 +$ jira issue view ISSUE-1 ``` ![View an issue](.github/assets/view.gif) @@ -487,7 +457,6 @@ $ jira issue view ISSUE-1 --comments 5 ``` #### Link - The `link` command lets you link two issues. ```sh @@ -499,7 +468,6 @@ $ jira issue link ISSUE-1 ISSUE-2 Blocks ``` ##### Remote - The `remote` command lets you add a remote web link to an issue. ```sh @@ -511,7 +479,6 @@ $ jira issue link remote ISSUE-1 https://example.com "Example text" ``` #### Unlink - The `unlink` command lets you unlink two linked issues. ```sh @@ -523,7 +490,6 @@ $ jira issue unlink ISSUE-1 ISSUE-2 ``` #### Clone - The `clone` command lets you clone an issue. You can update fields like summary, priority, assignee, labels, and components when cloning the issue. The command also allows you to replace a part of the string (case-sensitive) in summary and description using `--replace/-H` option. @@ -540,7 +506,6 @@ $ jira issue clone ISSUE-1 -H"find me:replace with me" ``` #### Delete - The `delete` command lets you delete an issue. ```sh @@ -555,11 +520,9 @@ $ jira issue delete ISSUE-1 --cascade ``` #### Comment - The `comment` command provides a list of sub-commands to manage issue comments. ##### Add - The `add` command lets you add a comment to an issue. The command supports both [Github-flavored](https://github.github.com/gfm/) and [Jira-flavored](https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all) markdown for writing comment. You can load pre-defined templates using `--template` flag. @@ -587,7 +550,6 @@ $ echo "Comment from stdin" | jira issue comment add ISSUE-1 > [!NOTE] > For the comment body, the positional argument always takes precedence over the `--template` flag if both of them are passed. In the example below, the body will be picked from positional argument instead of the template. - ```sh jira issue comment add ISSUE-42 "comment body positional" --template - <<'EOF' comment body template @@ -595,11 +557,9 @@ EOF ``` #### Worklog - The `worklog` command provides a list of sub-commands to manage issue worklog (timelog). ##### Add - The `add` command lets you add a worklog to an issue. The command supports markdown for worklog comments. ```sh @@ -614,14 +574,12 @@ $ jira issue worklog add ISSUE-1 "10m" --comment "This is a comment" --no-input ``` ### Epic - Epics are displayed in an explorer view by default. You can output the results in a table view using the `--table` flag. When viewing epic issues, you can use all filters available for the issue command. See [usage](#navigation) to learn more about UI interaction. #### List - You can use all flags supported by `issue list` command here except for the issue type. ```sh @@ -648,7 +606,6 @@ $ jira epic list KEY-1 --order-by rank --reverse ``` #### Create - Creating an epic is the same as creating the issue except you also need to provide an epic name. ```sh @@ -660,7 +617,6 @@ $ jira epic create -n"Epic epic" -s"Everything" -yHigh -lbug -lurgent -b"Epic de ``` #### Add - The `add` command allows you to add issues to the epic. You can add up to 50 issues to the epic at once. ```sh @@ -672,7 +628,6 @@ $ jira epic add EPIC-KEY ISSUE-1 ISSUE-2 ``` #### Remove - The `remove` command allows you to remove issues from the epic. You can remove up to 50 issues from the epic at once. ```sh @@ -684,14 +639,12 @@ $ jira epic remove ISSUE-1 ISSUE-2 ``` ### Sprint - Sprints are displayed in an explorer view by default. You can output the results in a table view using the `--table` flag. When viewing sprint issues, you can use all filters available for the issue command. The tool only shows 25 recent sprints. See [usage](#navigation) to learn more about UI interaction. #### List - You can use all flags supported by `issue list` command to filter issues in the sprint. ```sh @@ -728,7 +681,6 @@ $ jira sprint list SPRINT_ID --order-by rank --reverse ``` #### Add - The `add` command allows you to add issues to the sprint. You can add up to 50 issues to the sprint at once. ```sh @@ -741,7 +693,7 @@ $ jira sprint add SPRINT_ID ISSUE-1 ISSUE-2 ### Releases -Interact with releases (project versions). +Interact with releases (project versions). Ensure the [feature is enabled](https://support.atlassian.com/jira-software-cloud/docs/enable-releases-and-versions/) on your instance. #### List @@ -762,7 +714,6 @@ $ jira release list --project KEY ```sh jira open ``` -
Navigate to the issue @@ -770,7 +721,6 @@ jira open ```sh jira open KEY-1 ``` -
List all projects you have access to @@ -778,7 +728,6 @@ jira open KEY-1 ```sh jira project list ``` -
List all boards in a project @@ -786,11 +735,9 @@ jira project list ```sh jira board list ``` -
## Scripts - Often times, you may want to use the output of the command to do something cool. However, the default interactive UI might not allow you to do that. The tool comes with the `--plain` flag that displays results in a simple layout that can then be manipulated from the shell script. @@ -816,7 +763,6 @@ Day #02: 10 Day #03: 21 ... ``` -
Number of tickets per sprint @@ -838,7 +784,6 @@ Sprint 2: 40 Sprint 1: 30 ... ``` -
Number of unique assignee per sprint @@ -859,7 +804,6 @@ Sprint 3: 5 Sprint 2: 4 Sprint 1: 3 ``` -
## Known Issues @@ -878,34 +822,28 @@ Please [open a discussion](https://github.com/ankitpokhrel/jira-cli/discussions/ - Rest of the features will be picked based on the [number of votes](https://github.com/ankitpokhrel/jira-cli/discussions/categories/ideas) on the particular feature. ## Development - 1. Clone the repo. - ```sh git clone git@github.com:ankitpokhrel/jira-cli.git ``` 2. Optional: If you want to run a Jira instance locally, you can use the following make recipe. The trial license key can be generated from the "Licenses" section in the [atlassian admin](https://my.atlassian.com). - ```sh make jira.server ``` 3. Make changes, build the binary, and test your changes. - ```sh make deps install ``` 4. Run CI steps locally before submitting a PR. - ```sh make ci ``` ## Support the project - Your suggestions and feedbacks are highly appreciated. Please feel free to [start a discussion](https://github.com/ankitpokhrel/jira-cli/discussions) or [create an issue](https://github.com/ankitpokhrel/jira-cli/issues/new) to share your experience with the tool or to From 0d2aa969454e39b86dff8159c60e8c147d6fd0cf Mon Sep 17 00:00:00 2001 From: Johannes Larsson Date: Thu, 2 Oct 2025 12:27:53 +0200 Subject: [PATCH 4/4] docs/auth: add cookie auth to docs and comments --- README.md | 12 ++++++------ internal/cmd/init/init.go | 2 +- internal/config/generator.go | 5 +++-- pkg/jira/types.go | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2b624951..264b9fa9 100644 --- a/README.md +++ b/README.md @@ -94,20 +94,19 @@ Follow the [installation guide](https://github.com/ankitpokhrel/jira-cli/wiki/In 2. Run `jira init`, select installation type as `Cloud`, and provide required details to generate a config file required for the tool. -#### Cloud server without personal access token / OAuth enabled +#### Cloud server where PAT or OAuth is unavailable -Some tenants have disabled the ability to create personal Jira API tokens. In these cases, the alternative is to use the browser session cookie/token `tenant.session.token`. Note that these tokens expire after one day. +Some tenants have disabled or restricted the ability to create personal Jira API tokens / OAuth credentials. In these cases, you can fall back to the browser session cookie `tenant.session.token`. Note that this cookie usually expires in about 24 hours, so you will need to refresh it periodically. -1. Log in to Jira with your browser. Open the developer tools and find the cookie value for tenant.session.token. Then set the environment variable `JIRA_API_TOKEN` to that value. +1. Log in to Jira with your browser. Open the developer tools (Application/Storage tab) and find the cookie value for `tenant.session.token`. Then set the environment variable `JIRA_API_TOKEN` to that value. ```sh export JIRA_API_TOKEN=ey.. ``` -2. Bootstrap your cli +2. Bootstrap your CLI ```sh - jira init --installation cloud --server https://.atlassian.net --auth-type cookie --project ABC ``` @@ -136,9 +135,10 @@ See [FAQs](https://github.com/ankitpokhrel/jira-cli/discussions/categories/faqs) #### Authentication types -The tool supports `basic`, `bearer` (Personal Access Token), and `mtls` (Client Certificates) authentication types. Basic auth is used by +The tool supports `basic`, `cookie` (browser session), `bearer` (Personal Access Token), and `mtls` (Client Certificates) authentication types. Basic auth is used by default. +* If you want to use a browser session cookie, set `--auth-type cookie` (or `JIRA_AUTH_TYPE=cookie`) and set `JIRA_API_TOKEN` to the value of `tenant.session.token`. * If you want to use PAT, you need to set `JIRA_AUTH_TYPE` as `bearer`. * If you want to use `mtls` run `jira init`. Select installation type `Local`, and then select authentication type as `mtls`. * In case `JIRA_API_TOKEN` variable is set it will be used together with `mtls`. diff --git a/internal/cmd/init/init.go b/internal/cmd/init/init.go index 74411226..1ee85d38 100644 --- a/internal/cmd/init/init.go +++ b/internal/cmd/init/init.go @@ -40,7 +40,7 @@ func NewCmdInit() *cobra.Command { cmd.Flags().String("installation", "", "Is this a 'cloud' or 'local' jira installation?") cmd.Flags().String("server", "", "Link to your jira server") cmd.Flags().String("login", "", "Jira login username or email based on your setup") - cmd.Flags().String("auth-type", "", "Authentication type can be basic, bearer or mtls") + cmd.Flags().String("auth-type", "", "Authentication type can be basic, cookie, bearer or mtls") cmd.Flags().String("project", "", "Your default project key") cmd.Flags().String("board", "", "Name of your default board in the project") cmd.Flags().Bool("force", false, "Forcefully override existing config if it exists") diff --git a/internal/config/generator.go b/internal/config/generator.go index 54396d05..492ca1b4 100644 --- a/internal/config/generator.go +++ b/internal/config/generator.go @@ -229,10 +229,11 @@ func (c *JiraCLIConfigGenerator) configureLocalAuthType() error { if c.usrCfg.AuthType == "" { qs := &survey.Select{ Message: "Authentication type:", - Help: `Authentication type coud be: basic (login), bearer (PAT) or mtls (client certs) + Help: `Authentication type could be: basic (login), cookie (browser session), bearer (PAT) or mtls (client certs) ? If you are using your login credentials, the auth type is probably 'basic' (most common for local installation) +? If you are using a browser session cookie, choose 'cookie' ? If you are using a personal access token, the auth type is probably 'bearer'`, - Options: []string{"basic", "bearer", "mtls"}, + Options: []string{"basic", "cookie", "bearer", "mtls"}, Default: "basic", } if err := survey.AskOne(qs, &authType); err != nil { diff --git a/pkg/jira/types.go b/pkg/jira/types.go index bea00ea6..7d711e05 100644 --- a/pkg/jira/types.go +++ b/pkg/jira/types.go @@ -7,16 +7,16 @@ import ( const ( // AuthTypeBasic is a basic auth. AuthTypeBasic AuthType = "basic" - // AuthTypeBasic is a cookie auth. + // AuthTypeCookie is a cookie (browser session) auth. AuthTypeCookie AuthType = "cookie" - // AuthTypeBearer is a bearer auth. + // AuthTypeBearer is a bearer (PAT) auth. AuthTypeBearer AuthType = "bearer" // AuthTypeMTLS is a mTLS auth. AuthTypeMTLS AuthType = "mtls" ) // AuthType is a jira authentication type. -// Currently supports basic and bearer (PAT). +// Currently supports basic, cookie, bearer (PAT) and mtls (client certificates). // Defaults to basic for empty or invalid value. type AuthType string