You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Help to resolve JIRA::HTTPError: Not Found error while executing a ruby file from policies file.
Behaviour
I am currently making use of .triage-policies file for some automation in which I have a function that uses the jira-ruby gem to connect to the ,local JIRA server setup.
The curent URL is of the format https://jira.xxx.xx
For the policies file I am currently using the gitlab-triage project, which has an option to mention a function which is written inside the custom .rb files and those functions are executed.
Approach
The following is the code snippet that is used to connect to the JIRA using the gem
# frozen_string_literal: true
require 'jira-ruby'
require 'json'
module Test
module Jira
# Connection to JIRA API.
class Connection
API_TOKEN = ENV.fetch('JIRA_USER_TOKEN', nil)
attr_reader :client
def initialize
@params = {
site: 'https://jira.xxx.xx:443',
context_path: '',
username: ENV.fetch('JIRA_USERNAME', nil),
password: ENV.fetch('JIRA_USER_TOKEN', nil),
auth_type: :basic,
use_ssl: true,
ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
}
@client = JIRA::Client.new(@params)
end
def find_project()
client.Project.find((ENV.fetch('JIRA_PROJECT_ID', nil)))
rescue JIRA::HTTPError => e
puts 'Error while finding project'
puts e.response.code
puts e.response.message
end
end
end
end
The code written above works fine if I write it inside a file called test.rb and execute it with the commands ruby test.rb OR bundle exec ruby test.rb. The output that I get in this approach is as below..
When I try to execute the same snippet of code but using the policies file... it gives me the following error.
[4] pry(#<Test::Jira::Connection>)> client.Project.find('<<id>>') JIRA::HTTPError: Not Found from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jira-ruby-2.2.0/lib/jira/request_client.rb:13:in request'
`
I am currently uncertain of why the issue is present only when I run the code using a policies file and not the standalone .rb file.
I have all the envand proxies setup, and I can get the data using the API call using Postman.
STRUCTURE OF THE POLICIES FILE
Any help would be great!
Thank you.
The text was updated successfully, but these errors were encountered:
Help to resolve JIRA::HTTPError: Not Found error while executing a ruby file from policies file.
Behaviour
.triage-policies
file for some automation in which I have a function that uses thejira-ruby
gem to connect to the ,local JIRA server setup.https://jira.xxx.xx
gitlab-triage
project, which has an option to mention a function which is written inside the custom.rb
files and those functions are executed.Approach
test.rb
and execute it with the commandsruby test.rb
ORbundle exec ruby test.rb
. The output that I get in this approach is as below..[4] pry(#<Test::Jira::Connection>)> client.Project.find('<<id>>') JIRA::HTTPError: Not Found from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jira-ruby-2.2.0/lib/jira/request_client.rb:13:in request'
`
I am currently uncertain of why the issue is present only when I run the code using a
policies
file and not the standalone.rb
file.I have all the
env
andproxies
setup, and I can get the data using the API call using Postman.Any help would be great!
Thank you.
The text was updated successfully, but these errors were encountered: