jira-ruby 2.3.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/dependabot.yml +6 -0
  5. data/.github/workflows/CI.yml +28 -0
  6. data/.github/workflows/codeql.yml +100 -0
  7. data/.github/workflows/rubocop.yml +18 -0
  8. data/.rubocop.yml +188 -0
  9. data/Gemfile +11 -3
  10. data/Guardfile +2 -0
  11. data/README.md +94 -18
  12. data/Rakefile +3 -4
  13. data/jira-ruby.gemspec +11 -17
  14. data/lib/jira/base.rb +37 -28
  15. data/lib/jira/base_factory.rb +4 -1
  16. data/lib/jira/client.rb +64 -46
  17. data/lib/jira/has_many_proxy.rb +4 -2
  18. data/lib/jira/http_client.rb +17 -13
  19. data/lib/jira/http_error.rb +4 -0
  20. data/lib/jira/jwt_client.rb +18 -42
  21. data/lib/jira/oauth_client.rb +6 -3
  22. data/lib/jira/railtie.rb +2 -0
  23. data/lib/jira/request_client.rb +5 -1
  24. data/lib/jira/resource/agile.rb +7 -9
  25. data/lib/jira/resource/applinks.rb +5 -3
  26. data/lib/jira/resource/attachment.rb +43 -3
  27. data/lib/jira/resource/board.rb +5 -3
  28. data/lib/jira/resource/board_configuration.rb +2 -0
  29. data/lib/jira/resource/comment.rb +2 -0
  30. data/lib/jira/resource/component.rb +2 -0
  31. data/lib/jira/resource/createmeta.rb +3 -1
  32. data/lib/jira/resource/field.rb +9 -4
  33. data/lib/jira/resource/filter.rb +2 -0
  34. data/lib/jira/resource/issue.rb +35 -44
  35. data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
  36. data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
  37. data/lib/jira/resource/issuelink.rb +2 -0
  38. data/lib/jira/resource/issuelinktype.rb +2 -0
  39. data/lib/jira/resource/issuetype.rb +2 -0
  40. data/lib/jira/resource/priority.rb +2 -0
  41. data/lib/jira/resource/project.rb +4 -2
  42. data/lib/jira/resource/rapidview.rb +5 -3
  43. data/lib/jira/resource/remotelink.rb +2 -0
  44. data/lib/jira/resource/resolution.rb +2 -0
  45. data/lib/jira/resource/serverinfo.rb +2 -0
  46. data/lib/jira/resource/sprint.rb +14 -23
  47. data/lib/jira/resource/status.rb +7 -1
  48. data/lib/jira/resource/status_category.rb +10 -0
  49. data/lib/jira/resource/suggested_issue.rb +2 -0
  50. data/lib/jira/resource/transition.rb +2 -0
  51. data/lib/jira/resource/user.rb +3 -1
  52. data/lib/jira/resource/version.rb +2 -0
  53. data/lib/jira/resource/watcher.rb +2 -1
  54. data/lib/jira/resource/webhook.rb +4 -2
  55. data/lib/jira/resource/worklog.rb +3 -2
  56. data/lib/jira/version.rb +3 -1
  57. data/lib/jira-ruby.rb +5 -3
  58. data/lib/tasks/generate.rake +4 -2
  59. data/spec/data/files/short.txt +1 -0
  60. data/spec/integration/attachment_spec.rb +3 -3
  61. data/spec/integration/comment_spec.rb +8 -8
  62. data/spec/integration/component_spec.rb +7 -7
  63. data/spec/integration/field_spec.rb +3 -3
  64. data/spec/integration/issue_spec.rb +20 -16
  65. data/spec/integration/issuelinktype_spec.rb +3 -3
  66. data/spec/integration/issuetype_spec.rb +3 -3
  67. data/spec/integration/priority_spec.rb +3 -3
  68. data/spec/integration/project_spec.rb +7 -7
  69. data/spec/integration/rapidview_spec.rb +9 -9
  70. data/spec/integration/resolution_spec.rb +3 -3
  71. data/spec/integration/status_category_spec.rb +20 -0
  72. data/spec/integration/status_spec.rb +4 -8
  73. data/spec/integration/transition_spec.rb +2 -2
  74. data/spec/integration/user_spec.rb +22 -8
  75. data/spec/integration/version_spec.rb +7 -7
  76. data/spec/integration/watcher_spec.rb +17 -18
  77. data/spec/integration/webhook.rb +5 -4
  78. data/spec/integration/worklog_spec.rb +8 -8
  79. data/spec/jira/base_factory_spec.rb +2 -1
  80. data/spec/jira/base_spec.rb +55 -41
  81. data/spec/jira/client_spec.rb +48 -34
  82. data/spec/jira/has_many_proxy_spec.rb +3 -3
  83. data/spec/jira/http_client_spec.rb +94 -27
  84. data/spec/jira/http_error_spec.rb +2 -2
  85. data/spec/jira/oauth_client_spec.rb +8 -6
  86. data/spec/jira/request_client_spec.rb +4 -4
  87. data/spec/jira/resource/agile_spec.rb +28 -28
  88. data/spec/jira/resource/attachment_spec.rb +142 -52
  89. data/spec/jira/resource/board_spec.rb +21 -20
  90. data/spec/jira/resource/createmeta_spec.rb +48 -48
  91. data/spec/jira/resource/field_spec.rb +30 -12
  92. data/spec/jira/resource/filter_spec.rb +4 -4
  93. data/spec/jira/resource/issue_picker_suggestions_spec.rb +17 -17
  94. data/spec/jira/resource/issue_spec.rb +43 -37
  95. data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
  96. data/spec/jira/resource/project_factory_spec.rb +3 -2
  97. data/spec/jira/resource/project_spec.rb +16 -16
  98. data/spec/jira/resource/sprint_spec.rb +70 -3
  99. data/spec/jira/resource/status_spec.rb +21 -0
  100. data/spec/jira/resource/user_factory_spec.rb +4 -4
  101. data/spec/jira/resource/worklog_spec.rb +3 -3
  102. data/spec/mock_responses/sprint/1.json +13 -0
  103. data/spec/mock_responses/status/1.json +8 -1
  104. data/spec/mock_responses/status.json +40 -5
  105. data/spec/mock_responses/statuscategory/1.json +7 -0
  106. data/spec/mock_responses/statuscategory.json +30 -0
  107. data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
  108. data/spec/spec_helper.rb +1 -0
  109. data/spec/support/clients_helper.rb +3 -5
  110. data/spec/support/shared_examples/integration.rb +25 -28
  111. metadata +25 -257
  112. data/.travis.yml +0 -9
  113. data/example.rb +0 -232
  114. data/http-basic-example.rb +0 -113
  115. data/lib/jira/resource/sprint_report.rb +0 -8
  116. data/lib/jira/tasks.rb +0 -0
  117. data/spec/jira/jwt_uri_builder_spec.rb +0 -59
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUMO Heavy Industries
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-23 00:00:00.000000000 Z
12
+ date: 2024-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -59,169 +59,33 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0.5'
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: 0.5.0
62
+ version: '1.0'
66
63
  type: :runtime
67
64
  prerelease: false
68
65
  version_requirements: !ruby/object:Gem::Requirement
69
66
  requirements:
70
67
  - - "~>"
71
68
  - !ruby/object:Gem::Version
72
- version: '0.5'
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 0.5.0
76
- - !ruby/object:Gem::Dependency
77
- name: guard
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2.13'
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 2.13.0
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - "~>"
91
- - !ruby/object:Gem::Version
92
- version: '2.13'
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: 2.13.0
96
- - !ruby/object:Gem::Dependency
97
- name: guard-rspec
98
- requirement: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '4.6'
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: 4.6.5
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - "~>"
111
- - !ruby/object:Gem::Version
112
- version: '4.6'
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: 4.6.5
116
- - !ruby/object:Gem::Dependency
117
- name: pry
118
- requirement: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: '0.10'
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: 0.10.3
126
- type: :development
127
- prerelease: false
128
- version_requirements: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - "~>"
131
- - !ruby/object:Gem::Version
132
- version: '0.10'
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- version: 0.10.3
136
- - !ruby/object:Gem::Dependency
137
- name: railties
138
- requirement: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: '0'
143
- type: :development
144
- prerelease: false
145
- version_requirements: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- - !ruby/object:Gem::Dependency
151
- name: rake
152
- requirement: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - "~>"
155
- - !ruby/object:Gem::Version
156
- version: '10.3'
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: 10.3.2
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '10.3'
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- version: 10.3.2
170
- - !ruby/object:Gem::Dependency
171
- name: rspec
172
- requirement: !ruby/object:Gem::Requirement
173
- requirements:
174
- - - "~>"
175
- - !ruby/object:Gem::Version
176
- version: '3.0'
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- version: 3.0.0
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: '3.0'
187
- - - ">="
188
- - !ruby/object:Gem::Version
189
- version: 3.0.0
190
- - !ruby/object:Gem::Dependency
191
- name: webmock
192
- requirement: !ruby/object:Gem::Requirement
193
- requirements:
194
- - - "~>"
195
- - !ruby/object:Gem::Version
196
- version: '1.18'
197
- - - ">="
198
- - !ruby/object:Gem::Version
199
- version: 1.18.0
200
- type: :development
201
- prerelease: false
202
- version_requirements: !ruby/object:Gem::Requirement
203
- requirements:
204
- - - "~>"
205
- - !ruby/object:Gem::Version
206
- version: '1.18'
207
- - - ">="
208
- - !ruby/object:Gem::Version
209
- version: 1.18.0
69
+ version: '1.0'
210
70
  description: API for JIRA
211
71
  email:
212
72
  executables: []
213
73
  extensions: []
214
74
  extra_rdoc_files: []
215
75
  files:
76
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
77
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
78
+ - ".github/dependabot.yml"
79
+ - ".github/workflows/CI.yml"
80
+ - ".github/workflows/codeql.yml"
81
+ - ".github/workflows/rubocop.yml"
216
82
  - ".gitignore"
217
- - ".travis.yml"
83
+ - ".rubocop.yml"
218
84
  - Gemfile
219
85
  - Guardfile
220
86
  - LICENSE
221
87
  - README.md
222
88
  - Rakefile
223
- - example.rb
224
- - http-basic-example.rb
225
89
  - jira-ruby.gemspec
226
90
  - lib/jira-ruby.rb
227
91
  - lib/jira/base.rb
@@ -257,8 +121,8 @@ files:
257
121
  - lib/jira/resource/resolution.rb
258
122
  - lib/jira/resource/serverinfo.rb
259
123
  - lib/jira/resource/sprint.rb
260
- - lib/jira/resource/sprint_report.rb
261
124
  - lib/jira/resource/status.rb
125
+ - lib/jira/resource/status_category.rb
262
126
  - lib/jira/resource/suggested_issue.rb
263
127
  - lib/jira/resource/transition.rb
264
128
  - lib/jira/resource/user.rb
@@ -266,9 +130,9 @@ files:
266
130
  - lib/jira/resource/watcher.rb
267
131
  - lib/jira/resource/webhook.rb
268
132
  - lib/jira/resource/worklog.rb
269
- - lib/jira/tasks.rb
270
133
  - lib/jira/version.rb
271
134
  - lib/tasks/generate.rake
135
+ - spec/data/files/short.txt
272
136
  - spec/integration/attachment_spec.rb
273
137
  - spec/integration/comment_spec.rb
274
138
  - spec/integration/component_spec.rb
@@ -280,6 +144,7 @@ files:
280
144
  - spec/integration/project_spec.rb
281
145
  - spec/integration/rapidview_spec.rb
282
146
  - spec/integration/resolution_spec.rb
147
+ - spec/integration/status_category_spec.rb
283
148
  - spec/integration/status_spec.rb
284
149
  - spec/integration/transition_spec.rb
285
150
  - spec/integration/user_spec.rb
@@ -293,7 +158,6 @@ files:
293
158
  - spec/jira/has_many_proxy_spec.rb
294
159
  - spec/jira/http_client_spec.rb
295
160
  - spec/jira/http_error_spec.rb
296
- - spec/jira/jwt_uri_builder_spec.rb
297
161
  - spec/jira/oauth_client_spec.rb
298
162
  - spec/jira/request_client_spec.rb
299
163
  - spec/jira/resource/agile_spec.rb
@@ -309,6 +173,7 @@ files:
309
173
  - spec/jira/resource/project_factory_spec.rb
310
174
  - spec/jira/resource/project_spec.rb
311
175
  - spec/jira/resource/sprint_spec.rb
176
+ - spec/jira/resource/status_spec.rb
312
177
  - spec/jira/resource/user_factory_spec.rb
313
178
  - spec/jira/resource/worklog_spec.rb
314
179
  - spec/mock_responses/board/1.json
@@ -354,10 +219,13 @@ files:
354
219
  - spec/mock_responses/rapidview/SAMPLEPROJECT.json
355
220
  - spec/mock_responses/resolution.json
356
221
  - spec/mock_responses/resolution/1.json
222
+ - spec/mock_responses/sprint/1.json
357
223
  - spec/mock_responses/sprint/1_issues.json
358
224
  - spec/mock_responses/status.json
359
225
  - spec/mock_responses/status/1.json
360
- - spec/mock_responses/user_username=admin.json
226
+ - spec/mock_responses/statuscategory.json
227
+ - spec/mock_responses/statuscategory/1.json
228
+ - spec/mock_responses/user_accountId=1234567890abcdef01234567.json
361
229
  - spec/mock_responses/version.post.json
362
230
  - spec/mock_responses/version/10000.invalid.put.json
363
231
  - spec/mock_responses/version/10000.json
@@ -375,6 +243,7 @@ licenses:
375
243
  - MIT
376
244
  metadata:
377
245
  source_code_uri: https://github.com/sumoheavy/jira-ruby
246
+ rubygems_mfa_required: 'true'
378
247
  post_install_message:
379
248
  rdoc_options: []
380
249
  require_paths:
@@ -383,116 +252,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
383
252
  requirements:
384
253
  - - ">="
385
254
  - !ruby/object:Gem::Version
386
- version: 1.9.3
255
+ version: 3.1.0
387
256
  required_rubygems_version: !ruby/object:Gem::Requirement
388
257
  requirements:
389
- - - ">="
258
+ - - ">"
390
259
  - !ruby/object:Gem::Version
391
- version: '0'
260
+ version: 1.3.1
392
261
  requirements: []
393
- rubygems_version: 3.3.7
262
+ rubygems_version: 3.3.3
394
263
  signing_key:
395
264
  specification_version: 4
396
265
  summary: Ruby Gem for use with the Atlassian JIRA REST API
397
- test_files:
398
- - spec/integration/attachment_spec.rb
399
- - spec/integration/comment_spec.rb
400
- - spec/integration/component_spec.rb
401
- - spec/integration/field_spec.rb
402
- - spec/integration/issue_spec.rb
403
- - spec/integration/issuelinktype_spec.rb
404
- - spec/integration/issuetype_spec.rb
405
- - spec/integration/priority_spec.rb
406
- - spec/integration/project_spec.rb
407
- - spec/integration/rapidview_spec.rb
408
- - spec/integration/resolution_spec.rb
409
- - spec/integration/status_spec.rb
410
- - spec/integration/transition_spec.rb
411
- - spec/integration/user_spec.rb
412
- - spec/integration/version_spec.rb
413
- - spec/integration/watcher_spec.rb
414
- - spec/integration/webhook.rb
415
- - spec/integration/worklog_spec.rb
416
- - spec/jira/base_factory_spec.rb
417
- - spec/jira/base_spec.rb
418
- - spec/jira/client_spec.rb
419
- - spec/jira/has_many_proxy_spec.rb
420
- - spec/jira/http_client_spec.rb
421
- - spec/jira/http_error_spec.rb
422
- - spec/jira/jwt_uri_builder_spec.rb
423
- - spec/jira/oauth_client_spec.rb
424
- - spec/jira/request_client_spec.rb
425
- - spec/jira/resource/agile_spec.rb
426
- - spec/jira/resource/attachment_spec.rb
427
- - spec/jira/resource/board_spec.rb
428
- - spec/jira/resource/createmeta_spec.rb
429
- - spec/jira/resource/field_spec.rb
430
- - spec/jira/resource/filter_spec.rb
431
- - spec/jira/resource/issue_picker_suggestions_spec.rb
432
- - spec/jira/resource/issue_spec.rb
433
- - spec/jira/resource/issuelink_spec.rb
434
- - spec/jira/resource/jira_picker_suggestions_issue_spec.rb
435
- - spec/jira/resource/project_factory_spec.rb
436
- - spec/jira/resource/project_spec.rb
437
- - spec/jira/resource/sprint_spec.rb
438
- - spec/jira/resource/user_factory_spec.rb
439
- - spec/jira/resource/worklog_spec.rb
440
- - spec/mock_responses/board/1.json
441
- - spec/mock_responses/board/1_issues.json
442
- - spec/mock_responses/component.post.json
443
- - spec/mock_responses/component/10000.invalid.put.json
444
- - spec/mock_responses/component/10000.json
445
- - spec/mock_responses/component/10000.put.json
446
- - spec/mock_responses/empty_issues.json
447
- - spec/mock_responses/field.json
448
- - spec/mock_responses/field/1.json
449
- - spec/mock_responses/issue.json
450
- - spec/mock_responses/issue.post.json
451
- - spec/mock_responses/issue/10002.invalid.put.json
452
- - spec/mock_responses/issue/10002.json
453
- - spec/mock_responses/issue/10002.put.missing_field_update.json
454
- - spec/mock_responses/issue/10002/attachments/10000.json
455
- - spec/mock_responses/issue/10002/comment.json
456
- - spec/mock_responses/issue/10002/comment.post.json
457
- - spec/mock_responses/issue/10002/comment/10000.json
458
- - spec/mock_responses/issue/10002/comment/10000.put.json
459
- - spec/mock_responses/issue/10002/transitions.json
460
- - spec/mock_responses/issue/10002/transitions.post.json
461
- - spec/mock_responses/issue/10002/watchers.json
462
- - spec/mock_responses/issue/10002/worklog.json
463
- - spec/mock_responses/issue/10002/worklog.post.json
464
- - spec/mock_responses/issue/10002/worklog/10000.json
465
- - spec/mock_responses/issue/10002/worklog/10000.put.json
466
- - spec/mock_responses/issueLinkType.json
467
- - spec/mock_responses/issueLinkType/10000.json
468
- - spec/mock_responses/issuetype.json
469
- - spec/mock_responses/issuetype/5.json
470
- - spec/mock_responses/jira/rest/webhooks/1.0/webhook.json
471
- - spec/mock_responses/jira/rest/webhooks/1.0/webhook/2.json
472
- - spec/mock_responses/priority.json
473
- - spec/mock_responses/priority/1.json
474
- - spec/mock_responses/project.json
475
- - spec/mock_responses/project/SAMPLEPROJECT.issues.json
476
- - spec/mock_responses/project/SAMPLEPROJECT.json
477
- - spec/mock_responses/rapidview.json
478
- - spec/mock_responses/rapidview/SAMPLEPROJECT.issues.full.json
479
- - spec/mock_responses/rapidview/SAMPLEPROJECT.issues.json
480
- - spec/mock_responses/rapidview/SAMPLEPROJECT.json
481
- - spec/mock_responses/resolution.json
482
- - spec/mock_responses/resolution/1.json
483
- - spec/mock_responses/sprint/1_issues.json
484
- - spec/mock_responses/status.json
485
- - spec/mock_responses/status/1.json
486
- - spec/mock_responses/user_username=admin.json
487
- - spec/mock_responses/version.post.json
488
- - spec/mock_responses/version/10000.invalid.put.json
489
- - spec/mock_responses/version/10000.json
490
- - spec/mock_responses/version/10000.put.json
491
- - spec/mock_responses/webhook.json
492
- - spec/mock_responses/webhook/webhook.json
493
- - spec/spec_helper.rb
494
- - spec/support/clients_helper.rb
495
- - spec/support/matchers/have_attributes.rb
496
- - spec/support/matchers/have_many.rb
497
- - spec/support/matchers/have_one.rb
498
- - spec/support/shared_examples/integration.rb
266
+ test_files: []
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4
4
- - 2.5
5
- - 2.6
6
- - 2.7
7
- before_script:
8
- - rake jira:generate_public_cert
9
- script: bundle exec rake spec
data/example.rb DELETED
@@ -1,232 +0,0 @@
1
- require 'pp'
2
- require './lib/jira-ruby'
3
-
4
- CONSUMER_KEY = 'test'
5
- SITE = 'https://test.jira.com'
6
-
7
- options = {
8
- :private_key_file => "rsakey.pem",
9
- :context_path => '',
10
- :consumer_key => CONSUMER_KEY,
11
- :site => SITE
12
- }
13
-
14
- client = JIRA::Client.new(options)
15
-
16
- if ARGV.length == 0
17
- # If not passed any command line arguments, open a browser and prompt the
18
- # user for the OAuth verifier.
19
- request_token = client.request_token
20
- puts "Opening #{request_token.authorize_url}"
21
- system "open #{request_token.authorize_url}"
22
-
23
- puts "Enter the oauth_verifier: "
24
- oauth_verifier = gets.strip
25
-
26
- access_token = client.init_access_token(:oauth_verifier => oauth_verifier)
27
- puts "Access token: #{access_token.token} secret: #{access_token.secret}"
28
- elsif ARGV.length == 2
29
- # Otherwise assume the arguments are a previous access token and secret.
30
- access_token = client.set_access_token(ARGV[0], ARGV[1])
31
- else
32
- # Script must be passed 0 or 2 arguments
33
- raise "Usage: #{$0} [ token secret ]"
34
- end
35
-
36
- # Show all projects
37
- projects = client.Project.all
38
-
39
- projects.each do |project|
40
- puts "Project -> key: #{project.key}, name: #{project.name}"
41
- end
42
- issue = client.Issue.find('SAMPLEPROJECT-1')
43
- pp issue
44
-
45
- # # Handling fields by name, rather than by id
46
- # # ------------------------------------------
47
- # Cache the Field list from the server
48
- client.Field.map_fields
49
- # This allows use of friendlier names for custom fields
50
- # Say that 'Special Field' is customfield_12345
51
- # It becomes mapped to Special_Field which is usable as a method call
52
- #
53
- # Say that there is a second 'Special Field' is customfield_54321
54
- # Names are deduplicated so the second 'Special Field' becomes Special_Field_54321
55
- #
56
- # Names are massaged to get rid of special characters, and spaces
57
- # So 'Special & @ Field' becomes Special_____Field - not perfect, but usable
58
- old_way = issue.customfield_12345
59
- new_way = issue.Special_Field
60
- (old_way == new_way) && puts 'much easier'
61
- #
62
- # You can also specify fields to be returned in the response
63
- # This is especially useful in regards to shortening JQL query response times if performance becomes an issue
64
- client.Issue.jql(a_normal_jql_search, fields:[:description, :summary, :Special_field, :created])
65
- # Or you could always do it the old way - if you can remember the custom field numbers...
66
- client.Issue.jql(a_normal_jql_search, fields:[:description, :summary, :customfield_1234, :created])
67
- # You can also specify the maximum number of results to be returned in the response, i.e. 500
68
- client.Issue.jql(a_normal_jql_search, max_results: 500)
69
-
70
- # # Find a specific project by key
71
- # # ------------------------------
72
- # project = client.Project.find('SAMPLEPROJECT')
73
- # pp project
74
- # project.issues.each do |issue|
75
- # puts "#{issue.id} - #{issue.fields['summary']}"
76
- # end
77
- #
78
- # # List all Issues
79
- # # ---------------
80
- # client.Issue.all.each do |issue|
81
- # puts "#{issue.id} - #{issue.fields['summary']}"
82
- # end
83
- #
84
- # # List issues by JQL query
85
- # # ------------------------
86
- # client.Issue.jql('PROJECT = "SAMPLEPROJECT"', [comments, summary]).each do |issue|
87
- # puts "#{issue.id} - #{issue.fields['summary']}"
88
- # end
89
- #
90
- # # Delete an issue
91
- # # ---------------
92
- # issue = client.Issue.find('SAMPLEPROJECT-2')
93
- # if issue.delete
94
- # puts "Delete of issue SAMPLEPROJECT-2 sucessful"
95
- # else
96
- # puts "Delete of issue SAMPLEPROJECT-2 failed"
97
- # end
98
- #
99
- # # Create an issue
100
- # # ---------------
101
- # issue = client.Issue.build
102
- # labels = ['label1', 'label2']
103
- # issue.save({
104
- # "fields" => {
105
- # "summary" => "blarg from in example.rb",
106
- # "project" => {"key" => "SAMPLEPROJECT"},
107
- # "issuetype" => {"id" => "3"},
108
- # "labels" => labels,
109
- # "priority" => {"id" => "1"}
110
- # }
111
- # })
112
- # issue.fetch
113
- # pp issue
114
- #
115
- # # Update an issue
116
- # # ---------------
117
- # issue = client.Issue.find("10002")
118
- # issue.save({"fields"=>{"summary"=>"EVEN MOOOOOOARRR NINJAAAA!"}})
119
- # pp issue
120
- #
121
- # # Transition an issue
122
- # # -------------------
123
- # issue_transition = issue.transitions.build
124
- # issue_transition.save!('transition' => {'id' => transition_id})
125
- #
126
- # # Change assignee
127
- # # -------------------
128
- # issue.save({'fields' => {'assignee' => {'name' => person_name}}})
129
- #
130
- # # Find a user
131
- # # -----------
132
- # user = client.User.find('admin')
133
- # pp user
134
- #
135
- # # Get all issue watchers
136
- # # ----------------------
137
- # issue = client.Issue.find("10002")
138
- # watchers = issue.watchers.all
139
- # watchers = client.Watcher.all(:issue => issue)
140
- # # Get all issue types
141
- # # -------------------
142
- # issuetypes = client.Issuetype.all
143
- # pp issuetypes
144
- #
145
- # # Get a single issue type
146
- # # -----------------------
147
- # issuetype = client.Issuetype.find('5')
148
- # pp issuetype
149
- #
150
- # # Get all comments for an issue
151
- # # -----------------------------
152
- # issue.comments.each do |comment|
153
- # pp comment
154
- # end
155
- #
156
- # # Build and Save a comment
157
- # # ------------------------
158
- # comment = issue.comments.build
159
- # comment.save!(:body => "New comment from example script")
160
- #
161
- # # Delete a comment from the collection
162
- # # ------------------------------------
163
- # issue.comments.last.delete
164
- #
165
- # # Update an existing comment
166
- # # --------------------------
167
- # issue.comments.first.save({"body" => "an updated comment frome example.rb"})
168
-
169
-
170
- # # Add attachment to Issue
171
- # # ------------------------
172
- # issue = client.Issue.find('PROJ-1')
173
- # attachment = issue.attachments.build
174
- # attachment.save('file': '/path/to/file')
175
- #
176
-
177
- # List all available link types
178
- # ------------------------------
179
- pp client.Issuelinktype.all
180
-
181
- # List issue's links
182
- # -------------------------
183
- issue = client.Issue.find("10002")
184
- pp issue.issuelinks
185
-
186
- # Link two issues (on the same Jira instance)
187
- # --------------------------------------------
188
- link = client.Issuelink.build
189
- link.save(
190
- {
191
- :type => {:name => 'Relates'},
192
- :inwardIssue => {:key => 'AL-1'},
193
- :outwardIssue => {:key => 'AL-2'}
194
- }
195
- )
196
-
197
- # List issue's remote links
198
- # -------------------------
199
- pp issue.remotelink.all
200
-
201
- # Link two remote issues (on the different Jira instance)
202
- # In order to add remote links, you have to add
203
- # Application Links between two Jira instances first.
204
- # More information:
205
- # https://developer.atlassian.com/jiradev/jira-platform/guides/other/guide-jira-remote-issue-links/fields-in-remote-issue-links
206
- # http://stackoverflow.com/questions/29850252/jira-api-issuelink-connect-two-different-instances
207
- # -------------------------------------------------------
208
- client_1 = JIRA::Client.new(options)
209
- client_2 = JIRA::Client.new(options)
210
-
211
- # you have to search for your app id here, instead of getting the first
212
- client_2_app_link = client_2.ApplicationLink.manifest
213
- issue_1 = client_1.Issue.find('BB-2')
214
- issue_2 = client_2.Issue.find('AA-1')
215
-
216
- remote_link = issue_2.remotelink.build
217
-
218
- remote_link.save(
219
- {
220
- :globalId => "appId=#{client_2_app_link.id}&issueId=#{issue_1.id}",
221
- :application => {
222
- :type => 'com.atlassian.jira',
223
- :name => client_2_app_link['name']
224
- },
225
- :relationship => 'relates to',
226
-
227
- :object => {
228
- :url => client_1.options[:site] + client_1.options[:context_path] + "/browse/#{issue_1.key}",
229
- :title => issue_1.key,
230
- }
231
- }
232
- )