mikebowler / jirametrics

A tool to extract data from Jira and either generate reports or export to CSV files
Apache License 2.0
34 stars 1 forks source link

Atlassian Proxy Issue #29

Closed danagerous closed 2 weeks ago

danagerous commented 4 weeks ago

Unfortunately our Atlassian product URLs are behind a proxy and I am redirected for authentication causing the connection to fail and throw an error.

I tried encoding my login credentials instead of the token with no luck.

Error message included below. I get the same error with token and with encoded credentials.

I'm curious if there is a way to have these metrics work with a proxy?

Sample
  Downloading all statuses
Error #<JSON::ParserError:"unexpected token at '<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>302 Found</title>\n</head><body>\n<h1>Found</h1>\n<p>The document has moved <a href=\"<URL>">here</a>.</p>\n</body></html>\n'"> when parsing result: "
<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>302 Found</title>\n</head><body>\n<h1>Found</h1>\n<p>The document has moved <a href=\"<URL>">here</a>.</p>\n</body></html>\n"
  Downloading board configuration for board 12345
Error #<JSON::ParserError:"unexpected token at '
<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>302 Found</title>\n</head><body>\n<h1>Found</h1>\n<p>The document has moved <a href=\"<URL>"> when parsing result: "
<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>302 Found</title>\n</head><body>\n<h1>Found</h1>\n<p>The document has moved <a href=\"<URL>">here</a>.</p>\n</body></html>\n"
C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/downloader.rb:151:in `exit_if_call_failed': undefined method `[]' for nil (NoMethodError)

    return unless json['error'] || json['errorMessages'] || json['errorMessage']
                      ^^^^^^^^^
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/downloader.rb:172:in `download_board_configuration'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/downloader.rb:44:in `block in run'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/downloader.rb:43:in `each'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/downloader.rb:43:in `run'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/exporter.rb:67:in `block in download'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/exporter.rb:74:in `block in each_project_config'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/exporter.rb:73:in `each'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/exporter.rb:73:in `each_project_config'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics/exporter.rb:52:in `download'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/lib/jirametrics.rb:27:in `go'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
        from C:/Users/<USER>/.local/share/gem/ruby/3.3.0/gems/jirametrics-2.3/bin/jirametrics:5:in `<top (required)>'
        from C:/Users/<USER>/AppData/Local/Microsoft/WindowsApps/jirametrics:32:in `load'
        from C:/Users/<USER>/AppData/Local/Microsoft/WindowsApps/jirametrics:32:in `<main>'
mikebowler commented 4 weeks ago

Under the covers, we use curl for the actual network connection so if you set the http_proxy or https_proxy environment variables then it should just work.

I don't have a set up like that to test against so I can't be absolutely sure, but it seems like it would work. Let me know.

mishraomp commented 4 weeks ago

@mikebowler I think what we(@danagerous and I) need is a way to pass Basic Auth in the header

###
GET https://****/int/jira/browse/PMO-10405
Authorization: Basic username pwd

is this possible?

mikebowler commented 3 weeks ago

I've put a change into version 2.4pre2 to follow redirects. Please try this and see what result you get. You can install prerelease versions with:

gem install jirametrics --pre
mikebowler commented 3 weeks ago

Did this fix the problem you were having?

danagerous commented 2 weeks ago

Hi Mike. No. I was coming back to say this can be closed. I couldn't get it to work.