danger-jira_sync 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/README.md +7 -4
- data/lib/jira_sync/gem_version.rb +1 -1
- data/lib/jira_sync/plugin.rb +16 -7
- data/spec/fixtures/vcr_cassettes/default_success.yml +45 -30
- data/spec/jira_sync_spec.rb +34 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e005da62bab1b7ea6cbb618749b2eedf44e57f3009b9599e4a2a4f1e3da6bdc6
|
|
4
|
+
data.tar.gz: 7fcf16c36d8d4c3bfd0bca21ed6b38798b143106a675ad95459604000b501305
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27fd88ed0e8b653fce9a792392cdbad5ceb9b886d61ab14836f3ed9fd44eaa36ed70ae19125f40409ed7ab262a088356656cdaec9ac89638bfa797f961c04802
|
|
7
|
+
data.tar.gz: 92a365a21f013a2be562c27f354a249849510ef5f5b1427fd7fbe5c80fd2c5dda40923ca0d09fd6ef03ecc7d16d0b00e0dcc38c18bed721bc3db580b4f5fd5de
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
danger-jira_sync (0.0.
|
|
4
|
+
danger-jira_sync (0.0.7)
|
|
5
5
|
danger-plugin-api (~> 1.0)
|
|
6
6
|
jira-ruby (~> 1.5.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activesupport (5.2.
|
|
11
|
+
activesupport (5.2.1)
|
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
13
13
|
i18n (>= 0.7, < 2)
|
|
14
14
|
minitest (~> 5.1)
|
|
@@ -24,19 +24,19 @@ GEM
|
|
|
24
24
|
open4 (~> 1.3)
|
|
25
25
|
coderay (1.1.2)
|
|
26
26
|
colored2 (3.1.2)
|
|
27
|
-
concurrent-ruby (1.
|
|
27
|
+
concurrent-ruby (1.1.3)
|
|
28
28
|
cork (0.3.0)
|
|
29
29
|
colored2 (~> 3.1)
|
|
30
30
|
crack (0.4.3)
|
|
31
31
|
safe_yaml (~> 1.0.0)
|
|
32
|
-
danger (5.
|
|
32
|
+
danger (5.8.0)
|
|
33
33
|
claide (~> 1.0)
|
|
34
34
|
claide-plugins (>= 0.9.2)
|
|
35
35
|
colored2 (~> 3.1)
|
|
36
36
|
cork (~> 0.1)
|
|
37
37
|
faraday (~> 0.9)
|
|
38
38
|
faraday-http-cache (~> 1.0)
|
|
39
|
-
git (~> 1)
|
|
39
|
+
git (~> 1.5)
|
|
40
40
|
kramdown (~> 1.5)
|
|
41
41
|
no_proxy_fix
|
|
42
42
|
octokit (~> 4.7)
|
|
@@ -46,13 +46,13 @@ GEM
|
|
|
46
46
|
diff-lcs (1.3)
|
|
47
47
|
docile (1.3.1)
|
|
48
48
|
dotenv (2.4.0)
|
|
49
|
-
faraday (0.15.
|
|
49
|
+
faraday (0.15.3)
|
|
50
50
|
multipart-post (>= 1.2, < 3)
|
|
51
51
|
faraday-http-cache (1.3.1)
|
|
52
52
|
faraday (~> 0.8)
|
|
53
53
|
ffi (1.9.25)
|
|
54
54
|
formatador (0.2.5)
|
|
55
|
-
git (1.
|
|
55
|
+
git (1.5.0)
|
|
56
56
|
guard (2.14.2)
|
|
57
57
|
formatador (>= 0.2.4)
|
|
58
58
|
listen (>= 2.7, < 4.0)
|
|
@@ -68,7 +68,7 @@ GEM
|
|
|
68
68
|
guard-compat (~> 1.1)
|
|
69
69
|
rspec (>= 2.99.0, < 4.0)
|
|
70
70
|
hashdiff (0.3.7)
|
|
71
|
-
i18n (1.
|
|
71
|
+
i18n (1.1.1)
|
|
72
72
|
concurrent-ruby (~> 1.0)
|
|
73
73
|
jaro_winkler (1.5.1)
|
|
74
74
|
jira-ruby (1.5.0)
|
|
@@ -91,7 +91,7 @@ GEM
|
|
|
91
91
|
nenv (~> 0.1)
|
|
92
92
|
shellany (~> 0.0)
|
|
93
93
|
oauth (0.5.4)
|
|
94
|
-
octokit (4.
|
|
94
|
+
octokit (4.13.0)
|
|
95
95
|
sawyer (~> 0.8.0, >= 0.5.3)
|
|
96
96
|
open4 (1.3.4)
|
|
97
97
|
parallel (1.12.1)
|
data/README.md
CHANGED
|
@@ -29,20 +29,23 @@ Automatically label Pull Requests with the associated Jira issue's component nam
|
|
|
29
29
|
|
|
30
30
|
## Methods
|
|
31
31
|
|
|
32
|
-
### `configure(jira_url:, jira_username:, jira_api_token:)`
|
|
32
|
+
### `configure(jira_url:, jira_username:, jira_api_token:)`
|
|
33
33
|
Configures the Jira Client with your credentials
|
|
34
34
|
|
|
35
35
|
**Params**
|
|
36
|
-
- `jira_url [String]` - The full url to your Jira instance, e.g., "https://myjirainstance.atlassian.net"
|
|
36
|
+
- `jira_url [String]` - The full url to your Jira instance, e.g., "https://myjirainstance.atlassian.net"
|
|
37
37
|
- `jira_username [String]` - The username to use for accessing the Jira instance. Commonly, this is an email address
|
|
38
38
|
- `jira_api_token [String]` - The API key to use to access the Jira instance. Generate one here: https://id.atlassian.com/manage/api-tokens
|
|
39
39
|
|
|
40
40
|
**Returns**
|
|
41
41
|
- `[JIRA::Client]` - The underlying `JIRA::Client` instance
|
|
42
42
|
|
|
43
|
-
### `autolabel_pull_request(issue_prefixes)`
|
|
43
|
+
### `autolabel_pull_request(issue_prefixes)`
|
|
44
44
|
Labels the Pull Request with Jira Project Keys and Component Names
|
|
45
45
|
|
|
46
|
+
### `autolabel_pull_request(issue_prefixes, project: true, components: true, labels: true)`
|
|
47
|
+
Labels the Pull Request with Jira Project Keys, Component Names, and Labels
|
|
48
|
+
|
|
46
49
|
**Params**
|
|
47
50
|
- `issue_prefixes [Array<String>]` - An array of issue key prefixes; this is often the project key. These must be present in the title or body of the Pull Request
|
|
48
51
|
|
|
@@ -64,4 +67,4 @@ Labels the Pull Request with Jira Project Keys and Component Names
|
|
|
64
67
|
|
|
65
68
|
Before committing, check to see if you have created or changed any fixtures in `/spec/fixtures/vcr_cassettes`. If you have, it is possible that the changed file contains your credentials. Manually remove your credentials from these fixture files
|
|
66
69
|
|
|
67
|
-
When a new HTTP request is made that [VCR](https://github.com/vcr/vcr) hasn't seen before, it will record the response from the server and play it back in subsequent HTTP requests to the same URL with the same headers. This means that if a new request is made in the tests, it will actually make a request to the server in order to record the response. For this reason, development should be done within testing environments in GitHub and Jira Cloud
|
|
70
|
+
When a new HTTP request is made that [VCR](https://github.com/vcr/vcr) hasn't seen before, it will record the response from the server and play it back in subsequent HTTP requests to the same URL with the same headers. This means that if a new request is made in the tests, it will actually make a request to the server in order to record the response. For this reason, development should be done within testing environments in GitHub and Jira Cloud
|
data/lib/jira_sync/plugin.rb
CHANGED
|
@@ -61,18 +61,26 @@ module Danger
|
|
|
61
61
|
# @param issue_prefixes [Array<String>] An array of issue key prefixes;
|
|
62
62
|
# this is often the project key. These must be present in the title or
|
|
63
63
|
# body of the Pull Request
|
|
64
|
+
# @param project [Boolean] Label using the Jira Ticket's Project Key?
|
|
65
|
+
# @param components [Boolean] Label using the Jira Ticket's Component Names?
|
|
66
|
+
# @param labels [Boolean] Label using the Jira Ticket's Labels?
|
|
64
67
|
#
|
|
65
68
|
# @return [Array<String>, nil] The list of project & component labels
|
|
66
69
|
# that were applied or nil if no issue or labels were found
|
|
67
70
|
#
|
|
68
|
-
def autolabel_pull_request(issue_prefixes)
|
|
71
|
+
def autolabel_pull_request(issue_prefixes, project: true, components: true, labels: false)
|
|
69
72
|
raise NotConfiguredError unless @jira_client
|
|
70
73
|
raise(ArgumentError, "issue_prefixes cannot be empty") if issue_prefixes.empty?
|
|
71
74
|
|
|
72
75
|
issue_keys = extract_issue_keys_from_pull_request(issue_prefixes)
|
|
73
76
|
return if issue_keys.empty?
|
|
74
77
|
|
|
75
|
-
labels = fetch_labels_from_issues(
|
|
78
|
+
labels = fetch_labels_from_issues(
|
|
79
|
+
issue_keys,
|
|
80
|
+
project: project,
|
|
81
|
+
components: components,
|
|
82
|
+
labels: labels
|
|
83
|
+
)
|
|
76
84
|
return if labels.empty?
|
|
77
85
|
|
|
78
86
|
create_missing_github_labels(labels)
|
|
@@ -108,20 +116,21 @@ module Danger
|
|
|
108
116
|
keys.compact.uniq
|
|
109
117
|
end
|
|
110
118
|
|
|
111
|
-
def fetch_labels_from_issues(issue_keys)
|
|
112
|
-
|
|
119
|
+
def fetch_labels_from_issues(issue_keys, project: true, components: true, labels: false)
|
|
120
|
+
issue_labels = []
|
|
113
121
|
issue_keys.each do |key|
|
|
114
122
|
begin
|
|
115
123
|
issue = @jira_client.Issue.find(key)
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
issue_labels << issue.project.key if project
|
|
125
|
+
issue_labels += issue.components.map(&:name) if components
|
|
126
|
+
issue_labels += issue.fields["labels"] if labels
|
|
118
127
|
rescue JIRA::HTTPError => e
|
|
119
128
|
warn "#{e.code} Error while retrieving JIRA issue \"#{key}\": #{e.message}"
|
|
120
129
|
# No reason to continue if Unauthorized
|
|
121
130
|
break if e.code == 503
|
|
122
131
|
end
|
|
123
132
|
end
|
|
124
|
-
|
|
133
|
+
issue_labels.compact.uniq
|
|
125
134
|
end
|
|
126
135
|
|
|
127
136
|
def create_missing_github_labels(labels)
|
|
@@ -16,10 +16,10 @@ http_interactions:
|
|
|
16
16
|
response:
|
|
17
17
|
status:
|
|
18
18
|
code: 200
|
|
19
|
-
message:
|
|
19
|
+
message: ''
|
|
20
20
|
headers:
|
|
21
21
|
Server:
|
|
22
|
-
- Atlassian Proxy/
|
|
22
|
+
- Atlassian Proxy/1.13.6.2
|
|
23
23
|
Vary:
|
|
24
24
|
- Accept-Encoding
|
|
25
25
|
Cache-Control:
|
|
@@ -29,13 +29,17 @@ http_interactions:
|
|
|
29
29
|
Strict-Transport-Security:
|
|
30
30
|
- max-age=315360000; includeSubDomains; preload
|
|
31
31
|
Date:
|
|
32
|
-
-
|
|
32
|
+
- Sun, 11 Nov 2018 05:14:13 GMT
|
|
33
|
+
Atl-Traceid:
|
|
34
|
+
- 86165e23803a5f82
|
|
33
35
|
X-Arequestid:
|
|
34
|
-
-
|
|
36
|
+
- 067abea6-8b9c-4a04-ab66-84ce30a18913
|
|
35
37
|
X-Xss-Protection:
|
|
36
38
|
- 1; mode=block
|
|
37
39
|
Transfer-Encoding:
|
|
38
40
|
- chunked
|
|
41
|
+
Atl-Tcs-Time:
|
|
42
|
+
- '0'
|
|
39
43
|
X-Ausername:
|
|
40
44
|
- admin
|
|
41
45
|
X-Content-Type-Options:
|
|
@@ -45,14 +49,15 @@ http_interactions:
|
|
|
45
49
|
body:
|
|
46
50
|
encoding: ASCII-8BIT
|
|
47
51
|
string: '{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"10001","self":"<JIRA_URL>rest/api/2/issue/10001","key":"DEV-1","fields":{"issuetype":{"self":"<JIRA_URL>rest/api/2/issuetype/10001","id":"10001","description":"Stories
|
|
48
|
-
track functionality or features expressed as user goals.","iconUrl":"<JIRA_URL>secure/viewavatar?size=xsmall&avatarId=10315&avatarType=issuetype","name":"Story","subtask":false,"avatarId":10315},"timespent":null,"project":{"self":"<JIRA_URL>rest/api/2/project/10001","id":"10001","key":"DEV","name":"DEV","projectTypeKey":"software","avatarUrls":{"48x48":"<JIRA_URL>secure/projectavatar?avatarId=10324","24x24":"<JIRA_URL>secure/projectavatar?size=small&avatarId=10324","16x16":"<JIRA_URL>secure/projectavatar?size=xsmall&avatarId=10324","32x32":"<JIRA_URL>secure/projectavatar?size=medium&avatarId=10324"}},"fixVersions":[],"aggregatetimespent":null,"resolution":null,"resolutiondate":null,"workratio":-1,"watches":{"self":"<JIRA_URL>rest/api/2/issue/DEV-1/watchers","watchCount":1,"isWatching":true},"lastViewed":
|
|
52
|
+
track functionality or features expressed as user goals.","iconUrl":"<JIRA_URL>secure/viewavatar?size=xsmall&avatarId=10315&avatarType=issuetype","name":"Story","subtask":false,"avatarId":10315},"timespent":null,"project":{"self":"<JIRA_URL>rest/api/2/project/10001","id":"10001","key":"DEV","name":"DEV","projectTypeKey":"software","avatarUrls":{"48x48":"<JIRA_URL>secure/projectavatar?avatarId=10324","24x24":"<JIRA_URL>secure/projectavatar?size=small&avatarId=10324","16x16":"<JIRA_URL>secure/projectavatar?size=xsmall&avatarId=10324","32x32":"<JIRA_URL>secure/projectavatar?size=medium&avatarId=10324"}},"fixVersions":[],"aggregatetimespent":null,"resolution":null,"resolutiondate":null,"workratio":-1,"watches":{"self":"<JIRA_URL>rest/api/2/issue/DEV-1/watchers","watchCount":1,"isWatching":true},"lastViewed":"2018-11-10T20:47:23.351-0800","created":"2018-06-10T15:49:35.621-0700","customfield_10020":null,"customfield_10021":null,"customfield_10022":null,"priority":{"self":"<JIRA_URL>rest/api/2/priority/3","iconUrl":"<JIRA_URL>images/icons/priorities/medium.svg","name":"Medium","id":"3"},"labels":["label1","label2"],"customfield_10016":null,"customfield_10019":null,"aggregatetimeoriginalestimate":null,"timeestimate":null,"versions":[],"issuelinks":[],"assignee":null,"updated":"2018-11-10T20:47:23.286-0800","status":{"self":"<JIRA_URL>rest/api/2/status/10003","description":"","iconUrl":"<JIRA_URL>","name":"To
|
|
49
53
|
Do","id":"10003","statusCategory":{"self":"<JIRA_URL>rest/api/2/statuscategory/2","id":2,"key":"new","colorName":"blue-gray","name":"To
|
|
50
|
-
Do"}},"components":[{"self":"<JIRA_URL>rest/api/2/component/10003","id":"10003","name":"ComponentA"},{"self":"<JIRA_URL>rest/api/2/component/10005","id":"10005","name":"ComponentC"}],"timeoriginalestimate":null,"description":null,"customfield_10010":null,"customfield_10011":null,"customfield_10012":null,"customfield_10013":null,"customfield_10014":[],"
|
|
51
|
-
the
|
|
52
|
-
|
|
53
|
-
Menesini","active":true,"timeZone":"America/Los_Angeles"},"
|
|
54
|
+
Do"}},"components":[{"self":"<JIRA_URL>rest/api/2/component/10003","id":"10003","name":"ComponentA"},{"self":"<JIRA_URL>rest/api/2/component/10005","id":"10005","name":"ComponentC"}],"timeoriginalestimate":null,"description":null,"customfield_10010":null,"customfield_10011":null,"customfield_10012":null,"customfield_10013":null,"customfield_10014":[],"timetracking":{},"customfield_10015":null,"customfield_10006":null,"customfield_10007":{"hasEpicLinkFieldDependency":false,"showField":false,"nonEditableReason":{"reason":"PLUGIN_LICENSE_ERROR","message":"Portfolio
|
|
55
|
+
for Jira must be licensed for the Parent Link to be available."}},"security":null,"customfield_10008":null,"customfield_10009":"0|i00007:","aggregatetimeestimate":null,"attachment":[],"summary":"do
|
|
56
|
+
the thing ","creator":{"self":"<JIRA_URL>rest/api/2/user?accountId=5ac51680c5459746a4cf0e94","name":"admin","key":"admin","accountId":"5ac51680c5459746a4cf0e94","emailAddress":"<JIRA_USER>","avatarUrls":{"48x48":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue","24x24":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue","16x16":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue","32x32":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"},"displayName":"Ben
|
|
57
|
+
Menesini","active":true,"timeZone":"America/Los_Angeles"},"subtasks":[],"reporter":{"self":"<JIRA_URL>rest/api/2/user?accountId=5ac51680c5459746a4cf0e94","name":"admin","key":"admin","accountId":"5ac51680c5459746a4cf0e94","emailAddress":"<JIRA_USER>","avatarUrls":{"48x48":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue","24x24":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue","16x16":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue","32x32":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"},"displayName":"Ben
|
|
58
|
+
Menesini","active":true,"timeZone":"America/Los_Angeles"},"customfield_10000":"{}","aggregateprogress":{"progress":0,"total":0},"customfield_10001":null,"customfield_10002":null,"environment":null,"duedate":null,"progress":{"progress":0,"total":0},"votes":{"self":"<JIRA_URL>rest/api/2/issue/DEV-1/votes","votes":0,"hasVoted":false},"comment":{"comments":[],"maxResults":0,"total":0,"startAt":0},"worklog":{"startAt":0,"maxResults":20,"total":0,"worklogs":[]}}}'
|
|
54
59
|
http_version:
|
|
55
|
-
recorded_at:
|
|
60
|
+
recorded_at: Sun, 11 Nov 2018 05:14:13 GMT
|
|
56
61
|
- request:
|
|
57
62
|
method: get
|
|
58
63
|
uri: "<JIRA_URL>rest/api/2/issue/ABC-1"
|
|
@@ -69,10 +74,10 @@ http_interactions:
|
|
|
69
74
|
response:
|
|
70
75
|
status:
|
|
71
76
|
code: 200
|
|
72
|
-
message:
|
|
77
|
+
message: ''
|
|
73
78
|
headers:
|
|
74
79
|
Server:
|
|
75
|
-
- Atlassian Proxy/
|
|
80
|
+
- Atlassian Proxy/1.13.6.2
|
|
76
81
|
Vary:
|
|
77
82
|
- Accept-Encoding
|
|
78
83
|
Cache-Control:
|
|
@@ -82,13 +87,17 @@ http_interactions:
|
|
|
82
87
|
Strict-Transport-Security:
|
|
83
88
|
- max-age=315360000; includeSubDomains; preload
|
|
84
89
|
Date:
|
|
85
|
-
-
|
|
90
|
+
- Sun, 11 Nov 2018 05:14:13 GMT
|
|
91
|
+
Atl-Traceid:
|
|
92
|
+
- d6a88cf35c0936b0
|
|
86
93
|
X-Arequestid:
|
|
87
|
-
-
|
|
94
|
+
- 000c9435-c894-470d-860d-799dea1641fb
|
|
88
95
|
X-Xss-Protection:
|
|
89
96
|
- 1; mode=block
|
|
90
97
|
Transfer-Encoding:
|
|
91
98
|
- chunked
|
|
99
|
+
Atl-Tcs-Time:
|
|
100
|
+
- '1'
|
|
92
101
|
X-Ausername:
|
|
93
102
|
- admin
|
|
94
103
|
X-Content-Type-Options:
|
|
@@ -98,14 +107,15 @@ http_interactions:
|
|
|
98
107
|
body:
|
|
99
108
|
encoding: ASCII-8BIT
|
|
100
109
|
string: '{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"10002","self":"<JIRA_URL>rest/api/2/issue/10002","key":"ABC-1","fields":{"issuetype":{"self":"<JIRA_URL>rest/api/2/issuetype/10001","id":"10001","description":"Stories
|
|
101
|
-
track functionality or features expressed as user goals.","iconUrl":"<JIRA_URL>secure/viewavatar?size=xsmall&avatarId=10315&avatarType=issuetype","name":"Story","subtask":false,"avatarId":10315},"timespent":null,"project":{"self":"<JIRA_URL>rest/api/2/project/10002","id":"10002","key":"ABC","name":"ABC","projectTypeKey":"software","avatarUrls":{"48x48":"<JIRA_URL>secure/projectavatar?avatarId=10324","24x24":"<JIRA_URL>secure/projectavatar?size=small&avatarId=10324","16x16":"<JIRA_URL>secure/projectavatar?size=xsmall&avatarId=10324","32x32":"<JIRA_URL>secure/projectavatar?size=medium&avatarId=10324"}},"fixVersions":[],"aggregatetimespent":null,"resolution":null,"resolutiondate":null,"workratio":-1,"
|
|
110
|
+
track functionality or features expressed as user goals.","iconUrl":"<JIRA_URL>secure/viewavatar?size=xsmall&avatarId=10315&avatarType=issuetype","name":"Story","subtask":false,"avatarId":10315},"timespent":null,"project":{"self":"<JIRA_URL>rest/api/2/project/10002","id":"10002","key":"ABC","name":"ABC","projectTypeKey":"software","avatarUrls":{"48x48":"<JIRA_URL>secure/projectavatar?avatarId=10324","24x24":"<JIRA_URL>secure/projectavatar?size=small&avatarId=10324","16x16":"<JIRA_URL>secure/projectavatar?size=xsmall&avatarId=10324","32x32":"<JIRA_URL>secure/projectavatar?size=medium&avatarId=10324"}},"fixVersions":[],"aggregatetimespent":null,"resolution":null,"resolutiondate":null,"workratio":-1,"watches":{"self":"<JIRA_URL>rest/api/2/issue/ABC-1/watchers","watchCount":1,"isWatching":true},"lastViewed":"2018-11-10T20:47:12.635-0800","created":"2018-06-10T16:06:17.205-0700","customfield_10020":null,"customfield_10021":null,"customfield_10022":null,"priority":{"self":"<JIRA_URL>rest/api/2/priority/3","iconUrl":"<JIRA_URL>images/icons/priorities/medium.svg","name":"Medium","id":"3"},"labels":["label2"],"customfield_10016":null,"customfield_10019":null,"timeestimate":null,"aggregatetimeoriginalestimate":null,"versions":[],"issuelinks":[],"assignee":null,"updated":"2018-11-10T20:47:12.581-0800","status":{"self":"<JIRA_URL>rest/api/2/status/10003","description":"","iconUrl":"<JIRA_URL>","name":"To
|
|
102
111
|
Do","id":"10003","statusCategory":{"self":"<JIRA_URL>rest/api/2/statuscategory/2","id":2,"key":"new","colorName":"blue-gray","name":"To
|
|
103
|
-
Do"}},"components":[{"self":"<JIRA_URL>rest/api/2/component/10007","id":"10007","name":"ComponentB"}],"timeoriginalestimate":null,"description":null,"customfield_10010":null,"customfield_10011":null,"customfield_10012":null,"customfield_10013":null,"customfield_10014":[],"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Menesini","active":true,"timeZone":"America/Los_Angeles"},"
|
|
112
|
+
Do"}},"components":[{"self":"<JIRA_URL>rest/api/2/component/10007","id":"10007","name":"ComponentB"}],"timeoriginalestimate":null,"description":null,"customfield_10010":null,"customfield_10011":null,"customfield_10012":null,"customfield_10013":null,"customfield_10014":[],"customfield_10015":null,"timetracking":{},"customfield_10006":null,"security":null,"customfield_10007":{"hasEpicLinkFieldDependency":false,"showField":false,"nonEditableReason":{"reason":"PLUGIN_LICENSE_ERROR","message":"Portfolio
|
|
113
|
+
for Jira must be licensed for the Parent Link to be available."}},"customfield_10008":null,"attachment":[],"customfield_10009":"0|i0000f:","aggregatetimeestimate":null,"summary":"do
|
|
114
|
+
abc thing","creator":{"self":"<JIRA_URL>rest/api/2/user?accountId=5ac51680c5459746a4cf0e94","name":"admin","key":"admin","accountId":"5ac51680c5459746a4cf0e94","emailAddress":"<JIRA_USER>","avatarUrls":{"48x48":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue","24x24":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue","16x16":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue","32x32":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"},"displayName":"Ben
|
|
115
|
+
Menesini","active":true,"timeZone":"America/Los_Angeles"},"subtasks":[],"reporter":{"self":"<JIRA_URL>rest/api/2/user?accountId=5ac51680c5459746a4cf0e94","name":"admin","key":"admin","accountId":"5ac51680c5459746a4cf0e94","emailAddress":"<JIRA_USER>","avatarUrls":{"48x48":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue","24x24":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue","16x16":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue","32x32":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"},"displayName":"Ben
|
|
116
|
+
Menesini","active":true,"timeZone":"America/Los_Angeles"},"customfield_10000":"{}","aggregateprogress":{"progress":0,"total":0},"customfield_10001":null,"customfield_10002":null,"environment":null,"duedate":null,"progress":{"progress":0,"total":0},"votes":{"self":"<JIRA_URL>rest/api/2/issue/ABC-1/votes","votes":0,"hasVoted":false},"comment":{"comments":[],"maxResults":0,"total":0,"startAt":0},"worklog":{"startAt":0,"maxResults":20,"total":0,"worklogs":[]}}}'
|
|
107
117
|
http_version:
|
|
108
|
-
recorded_at:
|
|
118
|
+
recorded_at: Sun, 11 Nov 2018 05:14:13 GMT
|
|
109
119
|
- request:
|
|
110
120
|
method: get
|
|
111
121
|
uri: "<JIRA_URL>rest/api/2/issue/XYZ-1"
|
|
@@ -122,10 +132,10 @@ http_interactions:
|
|
|
122
132
|
response:
|
|
123
133
|
status:
|
|
124
134
|
code: 200
|
|
125
|
-
message:
|
|
135
|
+
message: ''
|
|
126
136
|
headers:
|
|
127
137
|
Server:
|
|
128
|
-
- Atlassian Proxy/
|
|
138
|
+
- Atlassian Proxy/1.13.6.2
|
|
129
139
|
Vary:
|
|
130
140
|
- Accept-Encoding
|
|
131
141
|
Cache-Control:
|
|
@@ -135,13 +145,17 @@ http_interactions:
|
|
|
135
145
|
Strict-Transport-Security:
|
|
136
146
|
- max-age=315360000; includeSubDomains; preload
|
|
137
147
|
Date:
|
|
138
|
-
-
|
|
148
|
+
- Sun, 11 Nov 2018 05:14:15 GMT
|
|
149
|
+
Atl-Traceid:
|
|
150
|
+
- d5cd7573b555be08
|
|
139
151
|
X-Arequestid:
|
|
140
|
-
-
|
|
152
|
+
- baf14ea0-099a-4318-b279-592bb5704893
|
|
141
153
|
X-Xss-Protection:
|
|
142
154
|
- 1; mode=block
|
|
143
155
|
Transfer-Encoding:
|
|
144
156
|
- chunked
|
|
157
|
+
Atl-Tcs-Time:
|
|
158
|
+
- '0'
|
|
145
159
|
X-Ausername:
|
|
146
160
|
- admin
|
|
147
161
|
X-Content-Type-Options:
|
|
@@ -151,12 +165,13 @@ http_interactions:
|
|
|
151
165
|
body:
|
|
152
166
|
encoding: ASCII-8BIT
|
|
153
167
|
string: '{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"10003","self":"<JIRA_URL>rest/api/2/issue/10003","key":"XYZ-1","fields":{"issuetype":{"self":"<JIRA_URL>rest/api/2/issuetype/10001","id":"10001","description":"Stories
|
|
154
|
-
track functionality or features expressed as user goals.","iconUrl":"<JIRA_URL>secure/viewavatar?size=xsmall&avatarId=10315&avatarType=issuetype","name":"Story","subtask":false,"avatarId":10315},"timespent":null,"project":{"self":"<JIRA_URL>rest/api/2/project/10003","id":"10003","key":"XYZ","name":"XYZ","projectTypeKey":"software","avatarUrls":{"48x48":"<JIRA_URL>secure/projectavatar?avatarId=10324","24x24":"<JIRA_URL>secure/projectavatar?size=small&avatarId=10324","16x16":"<JIRA_URL>secure/projectavatar?size=xsmall&avatarId=10324","32x32":"<JIRA_URL>secure/projectavatar?size=medium&avatarId=10324"}},"fixVersions":[],"aggregatetimespent":null,"resolution":null,"resolutiondate":null,"workratio":-1,"watches":{"self":"<JIRA_URL>rest/api/2/issue/XYZ-1/watchers","watchCount":1,"isWatching":true},"
|
|
168
|
+
track functionality or features expressed as user goals.","iconUrl":"<JIRA_URL>secure/viewavatar?size=xsmall&avatarId=10315&avatarType=issuetype","name":"Story","subtask":false,"avatarId":10315},"timespent":null,"project":{"self":"<JIRA_URL>rest/api/2/project/10003","id":"10003","key":"XYZ","name":"XYZ","projectTypeKey":"software","avatarUrls":{"48x48":"<JIRA_URL>secure/projectavatar?avatarId=10324","24x24":"<JIRA_URL>secure/projectavatar?size=small&avatarId=10324","16x16":"<JIRA_URL>secure/projectavatar?size=xsmall&avatarId=10324","32x32":"<JIRA_URL>secure/projectavatar?size=medium&avatarId=10324"}},"fixVersions":[],"aggregatetimespent":null,"resolution":null,"resolutiondate":null,"workratio":-1,"lastViewed":"2018-11-10T20:47:54.485-0800","watches":{"self":"<JIRA_URL>rest/api/2/issue/XYZ-1/watchers","watchCount":1,"isWatching":true},"created":"2018-06-10T16:06:37.918-0700","customfield_10020":null,"customfield_10021":null,"customfield_10022":null,"priority":{"self":"<JIRA_URL>rest/api/2/priority/3","iconUrl":"<JIRA_URL>images/icons/priorities/medium.svg","name":"Medium","id":"3"},"labels":["label1"],"customfield_10016":null,"customfield_10019":null,"aggregatetimeoriginalestimate":null,"timeestimate":null,"versions":[],"issuelinks":[],"assignee":null,"updated":"2018-11-10T20:47:02.317-0800","status":{"self":"<JIRA_URL>rest/api/2/status/10003","description":"","iconUrl":"<JIRA_URL>","name":"To
|
|
155
169
|
Do","id":"10003","statusCategory":{"self":"<JIRA_URL>rest/api/2/statuscategory/2","id":2,"key":"new","colorName":"blue-gray","name":"To
|
|
156
|
-
Do"}},"components":[{"self":"<JIRA_URL>rest/api/2/component/10011","id":"10011","name":"ComponentC"}],"timeoriginalestimate":null,"description":null,"customfield_10010":null,"customfield_10011":null,"customfield_10012":null,"customfield_10013":null,"customfield_10014":[],"customfield_10015":null,"timetracking":{},"customfield_10006":null,"
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
Menesini","active":true,"timeZone":"America/Los_Angeles"},"
|
|
170
|
+
Do"}},"components":[{"self":"<JIRA_URL>rest/api/2/component/10011","id":"10011","name":"ComponentC"}],"timeoriginalestimate":null,"description":null,"customfield_10010":null,"customfield_10011":null,"customfield_10012":null,"customfield_10013":null,"customfield_10014":[],"customfield_10015":null,"timetracking":{},"customfield_10006":null,"customfield_10007":{"hasEpicLinkFieldDependency":false,"showField":false,"nonEditableReason":{"reason":"PLUGIN_LICENSE_ERROR","message":"Portfolio
|
|
171
|
+
for Jira must be licensed for the Parent Link to be available."}},"security":null,"customfield_10008":null,"customfield_10009":"0|i0000n:","aggregatetimeestimate":null,"attachment":[],"summary":"do
|
|
172
|
+
xyz thing","creator":{"self":"<JIRA_URL>rest/api/2/user?accountId=5ac51680c5459746a4cf0e94","name":"admin","key":"admin","accountId":"5ac51680c5459746a4cf0e94","emailAddress":"<JIRA_USER>","avatarUrls":{"48x48":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue","24x24":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue","16x16":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue","32x32":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"},"displayName":"Ben
|
|
173
|
+
Menesini","active":true,"timeZone":"America/Los_Angeles"},"subtasks":[],"reporter":{"self":"<JIRA_URL>rest/api/2/user?accountId=5ac51680c5459746a4cf0e94","name":"admin","key":"admin","accountId":"5ac51680c5459746a4cf0e94","emailAddress":"<JIRA_USER>","avatarUrls":{"48x48":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue","24x24":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue","16x16":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue","32x32":"https://avatar-cdn.atlassian.com/ced2c1a305df6b35cd77e99ec6cfe02a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fced2c1a305df6b35cd77e99ec6cfe02a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"},"displayName":"Ben
|
|
174
|
+
Menesini","active":true,"timeZone":"America/Los_Angeles"},"customfield_10000":"{}","aggregateprogress":{"progress":0,"total":0},"customfield_10001":null,"customfield_10002":null,"environment":null,"duedate":null,"progress":{"progress":0,"total":0},"votes":{"self":"<JIRA_URL>rest/api/2/issue/XYZ-1/votes","votes":0,"hasVoted":false},"comment":{"comments":[],"maxResults":0,"total":0,"startAt":0},"worklog":{"startAt":0,"maxResults":20,"total":0,"worklogs":[]}}}'
|
|
160
175
|
http_version:
|
|
161
|
-
recorded_at:
|
|
176
|
+
recorded_at: Sun, 11 Nov 2018 05:14:15 GMT
|
|
162
177
|
recorded_with: VCR 4.0.0
|
data/spec/jira_sync_spec.rb
CHANGED
|
@@ -23,7 +23,8 @@ JIRA_ENVIRONMENT = {
|
|
|
23
23
|
issues: [
|
|
24
24
|
{
|
|
25
25
|
key: "DEV-1",
|
|
26
|
-
components: %w(ComponentA ComponentB)
|
|
26
|
+
components: %w(ComponentA ComponentB),
|
|
27
|
+
labels: %w(label1 label2)
|
|
27
28
|
}
|
|
28
29
|
]
|
|
29
30
|
},
|
|
@@ -32,7 +33,8 @@ JIRA_ENVIRONMENT = {
|
|
|
32
33
|
issues: [
|
|
33
34
|
{
|
|
34
35
|
key: "XYZ-1",
|
|
35
|
-
components: %w(ComponentC)
|
|
36
|
+
components: %w(ComponentC),
|
|
37
|
+
labels: %w(label1)
|
|
36
38
|
}
|
|
37
39
|
]
|
|
38
40
|
},
|
|
@@ -41,7 +43,8 @@ JIRA_ENVIRONMENT = {
|
|
|
41
43
|
issues: [
|
|
42
44
|
{
|
|
43
45
|
key: "ABC-1",
|
|
44
|
-
components: %w(ComponentB)
|
|
46
|
+
components: %w(ComponentB),
|
|
47
|
+
laels: %(label2)
|
|
45
48
|
}
|
|
46
49
|
]
|
|
47
50
|
}
|
|
@@ -185,6 +188,10 @@ RSpec.describe Danger::DangerJiraSync do
|
|
|
185
188
|
project_keys.compact.uniq
|
|
186
189
|
end
|
|
187
190
|
|
|
191
|
+
def expected_jira_ticket_labels
|
|
192
|
+
JIRA_ENVIRONMENT[:projects].map { |p| p[:issues].map { |i| i[:labels] } }.flatten.compact.uniq
|
|
193
|
+
end
|
|
194
|
+
|
|
188
195
|
def stub_jira_find_issue_response(code:, message:)
|
|
189
196
|
client = plugin.configure(jira_settings)
|
|
190
197
|
|
|
@@ -206,7 +213,7 @@ RSpec.describe Danger::DangerJiraSync do
|
|
|
206
213
|
stub_jira_find_issue_response(code: 503, message: "Unauthorized")
|
|
207
214
|
end
|
|
208
215
|
|
|
209
|
-
it "returns a list of labels that contains Jira component names" do
|
|
216
|
+
it "returns a list of labels that contains Jira component names by default" do
|
|
210
217
|
stub_github_api_labelling
|
|
211
218
|
|
|
212
219
|
labels = []
|
|
@@ -217,7 +224,7 @@ RSpec.describe Danger::DangerJiraSync do
|
|
|
217
224
|
expect(labels).to include(*pr_title_related_component_names)
|
|
218
225
|
end
|
|
219
226
|
|
|
220
|
-
it "returns a list of labels that contains Jira issue project keys" do
|
|
227
|
+
it "returns a list of labels that contains Jira issue project keys by default" do
|
|
221
228
|
stub_github_api_labelling
|
|
222
229
|
|
|
223
230
|
labels = []
|
|
@@ -228,6 +235,28 @@ RSpec.describe Danger::DangerJiraSync do
|
|
|
228
235
|
expect(labels).to include(*pr_title_related_project_keys)
|
|
229
236
|
end
|
|
230
237
|
|
|
238
|
+
it "does not return labels by default" do
|
|
239
|
+
stub_github_api_labelling
|
|
240
|
+
|
|
241
|
+
labels = []
|
|
242
|
+
VCR.use_cassette(:default_success, record: :new_episodes) do
|
|
243
|
+
labels = plugin.autolabel_pull_request(issue_prefixes)
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
expect(labels).not_to include(*expected_jira_ticket_labels)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it "returns a list of labels that contains JIRA issue labels" do
|
|
250
|
+
stub_github_api_labelling
|
|
251
|
+
|
|
252
|
+
labels = []
|
|
253
|
+
VCR.use_cassette(:default_success, record: :new_episodes) do
|
|
254
|
+
labels = plugin.autolabel_pull_request(issue_prefixes, labels: true)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
expect(labels).to include(*expected_jira_ticket_labels)
|
|
258
|
+
end
|
|
259
|
+
|
|
231
260
|
it "creates no warnings in the default case" do
|
|
232
261
|
stub_github_api_labelling
|
|
233
262
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: danger-jira_sync
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Menesini
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: danger-plugin-api
|