LoginSignup
2
3

More than 5 years have passed since last update.

JIRAのチケット情報を取得する

Last updated at Posted at 2017-05-02

API でチケット情報を取得する方法

Rubyは素人ですがとりあえず動いたので。

jira_api.rb
require "base64"
require 'open-uri'

jira_uri='https://jira.uri'

 入力
p 'JIRAのLoginIDを入力してください'
jira_user_id = gets
p 'JIRAのPasswordを入力してください'
jira_passwd = gets
p 'チケットIDを入れてください(ex. HOGE-128)'
ticket_id = gets

# 処理
auth_str = jira_user_id.chomp! + ':' + jira_passwd.chomp!
auth_base64 = Base64.encode64(auth_str)

res = open(jira_uri+'/rest/api/2/issue/' + ticket_id.chomp!,
    'Content-Type'=>'application/json',
    'Authorization'=> 'Basic ' + auth_base64
)
code, message = res.status

 出力
puts(code + ':' + message);
puts(res.read)
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3