jira-cli
jira-cli copied to clipboard
jira init not able to read the .netrc file
Describe the bug
After creating the ~/.netrc file with the following contents, when I run jira init it fails with 401.
machine <jira local server>
login <rbhanot>
password <token>
Please provide following details
- JiraCLI Version:
(Version="1.5.2", GitCommit="refs/tags/v1.5.2", CommitDate="1970-01-01T00:00:00+00:00", GoVersion="go1.23.4", Compiler="gc", Platform="darwin/arm64") - Are you using Jira cloud or on-premise jira server?
Jira on premise server - What operating system are you using? Also mention version.
macOs 15.2 - What terminal are you using? Also mention version.
Wezterm
To Reproduce
Steps to reproduce the behavior:
- Create
~/.netrcfile with contents as suggested here - Run
jira init
❯ jira init
? Installation type: Local
? Authentication type: bearer
? Link to Jira server: <https://jira01.....>
? Login username: <username>
✗ Received unexpected response '401 ' from jira. Please try again.
Expected behavior
The jira init should be able to read the config from ~/.netrc.
This actually looks like an issue with init command. Are you able to use .netrc after generating the config?
Nope... the config generation isn't even completing because init is failing,..
I meant if you can generate config using other methods (eg: setting JIRA_API_TOKEN) and then try to use .netrc, does it seem to work?
So if I run jira init with api token, it completes and config is generated. However if I open a new shell where the environment var is not set, jira issue list or any other fetching commands for that matter fails even if there is .netrc.
Bumping this. I cannot store the API token in my .zshrc since the config is shared and this key needs to stay local.
Currently does not work with .netrc in any capacity
@jacksonSingleton I agree, storing token in zshrc isn't even a good idea since its a token its suppose to be stored securely. A .netrc is the right place for it but apparantly it isn't working.
@ankitpokhrel Is there an eta on this, It kinda makes the tool unusable for me at the moment.
@ankitpokhrel Any plans to fix this bug? For someone who version controls his dotfiles, I can't keep the Jira API token in shell rc files.
@jacksonSingleton Not sure if you found a workaround to this but I ended up creating a function in zsh functions directory and then autoloading it at shell startup.
~/zsh-functions/set_token
_set_jira_token() {
export JIRA_API_TOKEN=$(rg password ~/.netrc | awk '{print $2}')
return 0
}
.zshrc snippet
CUSTOM_COMPLETION_DIR=($HOME/zsh_completions $zsh_functions)
typeset -U fpath=($CUSTOM_COMPLETION_DIR $fpath)
# Autoload all functions from zsh_functions directory
for func in $HOME/zsh_functions/*(.N:t); do
autoload -Uz $func
done
And then finally on shell startup I just do set_token and the token is set now.
The same story on Windows. In addition it's very strange that settings are stored in the special directory and file $HOME/.config/.jira/.config.yml but credentials can't be stored. And no integration with credentials manager at all