Class: CreateissueJira::Datafile
- Inherits:
-
Object
- Object
- CreateissueJira::Datafile
- Defined in:
- lib/createissue_jira.rb
Instance Method Summary collapse
- #business_acceptace(rowNo, colNo, acceptance_criteria_name) ⇒ Object
- #create_api(project_key, epic_key, assignee_id, label) ⇒ Object
- #description(rowNo, colNo, acceptance_criteria_name) ⇒ Object
- #jira_api_credentials(email, base_url, jira_api_token, assignee_id, acceptance_criteria_id) ⇒ Object
- #load_file(file_path, sheet_no, header_name) ⇒ Object
- #summary(idColNo, summaryRowNo, summaryColNo) ⇒ Object
Instance Method Details
#business_acceptace(rowNo, colNo, acceptance_criteria_name) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/createissue_jira.rb', line 50 def business_acceptace rowNo, colNo, acceptance_criteria_name rowNo = rowNo.to_i colNo = colNo.to_i @business_acceptance = [] @all_data.count.times do @business_acceptance.push(@datasheet.cell(rowNo, colNo).split(acceptance_criteria_name)[1]) rowNo += 1 end end |
#create_api(project_key, epic_key, assignee_id, label) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/createissue_jira.rb', line 60 def create_api project_key, epic_key, assignee_id, label i = 0 @summary.size.times do payload = { "fields": { "project": { "key": project_key }, "parent": { "key": epic_key }, "summary": @summary[i], "description": @description[i], "issuetype": { "name": "Story" }, "#{@acceptance_criteria_id}": @business_acceptance[i], "labels": [ label ] } } #2022 - atlassian - jira password updated with api token @auth = "Basic #{Base64.strict_encode64("#{@email + ":" + @jira_api_token}")}" response = RestClient.post( "#{@base_url}/rest/api/2/issue/", payload.to_json, headers = { content_type: :json, :Authorization => @auth } ) # extract the key @response = JSON.parse response.gsub(':', ':') @issue_key = @response["key"] # Assign the issue to someone # get the assignee id - by clicking on profile link : which will something like # https://abcperson.atlassian.net/jira/people/67gv54hmnj8798ujhhu # After - people what is there is the acount id : # request - put # endpoint : https://abcperson.atlassian.net/rest/api/2/issue/Issue-ID/assignee # body : {"accountID" : "67gv54hmnj8798ujhhu"} # expected response - 204 payload = { "accountId": assignee_id } url = "#{@base_url}/rest/api/2/issue/#{@issue_key}/assignee" response = RestClient.put( url, payload.to_json, headers = { # content_type: 'application/json', content_type: :json, # accept: :json, # accept: 'application,json', :Authorization => "Basic #{@jira_api_token}" } ) i += 1 end end |
#description(rowNo, colNo, acceptance_criteria_name) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/createissue_jira.rb', line 39 def description rowNo, colNo, acceptance_criteria_name rowNo = rowNo.to_i colNo = colNo.to_i rowNo @description = [] @all_data.count.times do @description.push(@datasheet.cell(rowNo, colNo).split(acceptance_criteria_name)[0]) rowNo += 1 end end |
#jira_api_credentials(email, base_url, jira_api_token, assignee_id, acceptance_criteria_id) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/createissue_jira.rb', line 11 def jira_api_credentials email,base_url, jira_api_token, assignee_id, acceptance_criteria_id @base_url = base_url @jira_api_token = jira_api_token @assignee_id = assignee_id @acceptance_criteria_id = acceptance_criteria_id @email = email end |
#load_file(file_path, sheet_no, header_name) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/createissue_jira.rb', line 19 def load_file (file_path, sheet_no, header_name) sheet_no = sheet_no.to_i xls = Roo::Spreadsheet.open(file_path) @datasheet = xls.sheet(sheet_no) @all_data = xls.parse(header_search: [/#{header_name}/]) end |
#summary(idColNo, summaryRowNo, summaryColNo) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/createissue_jira.rb', line 26 def summary idColNo, summaryRowNo, summaryColNo rowNo = summaryRowNo.to_i colNo = summaryColNo.to_i idColNo = idColNo.to_i @summary = [] rowNo @all_data.count.times do @summary.push(@datasheet.cell(rowNo, idColNo).rstrip + " " + " " + @datasheet.cell(rowNo, colNo)) rowNo += 1 end end |