groundskeeper-bitcore 0.10.0 → 0.11.0
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/README.md +7 -1
- data/lib/groundskeeper/bitbucket.rb +68 -0
- data/lib/groundskeeper/commands.rb +23 -3
- data/lib/groundskeeper/version.rb +1 -1
- data/lib/groundskeeper.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e55ad6626fe5d3681b91cd93237f9bdc1dc4c7cf317f0430b1ac73abeeac54ed
|
4
|
+
data.tar.gz: c6de6f01d01ac004f70304612cd077e97cb6e536c4ae80be335d022dffd8cfe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f63088adef14df37d86eeb22b7ae20ae7503092c778abd9692ee8f871473728135483eb48606cf0f69b3803b7cf73aad5676131a3f17b67be5c1bfa2ac6e7c7
|
7
|
+
data.tar.gz: e51ff74f8829aaac4b4503f4b31c7eef2114c242042d476be65df128dfd98c6afaac702f9604bb07c4a889f76ff6eea20b2bd8788de14373062e19c4444b07ad
|
data/README.md
CHANGED
@@ -23,6 +23,12 @@ export JIRA_API_TOKEN="my-token"
|
|
23
23
|
export JIRA_SITE="https://cbit123.atlassian.net"
|
24
24
|
```
|
25
25
|
|
26
|
+
For integration with Bitbucket, [create an app password](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html) with permissions of `Pull requests: Read Write`:
|
27
|
+
```bash
|
28
|
+
export BITBUCKET_USERNAME="bitbucket_username"
|
29
|
+
export BITBUCKET_APP_PASSWORD="app_password"
|
30
|
+
```
|
31
|
+
|
26
32
|
For integration with Sentry, find or create your auth token
|
27
33
|
[from here](https://sentry.io/settings/account/api/auth-tokens/) with the scopes `event:admin, event:read, member:read, org:read, project:read, project:releases, team:read`:
|
28
34
|
|
@@ -103,7 +109,7 @@ The gem is available as open source under the terms of the
|
|
103
109
|
|
104
110
|
## Code of Conduct
|
105
111
|
|
106
|
-
Everyone interacting in the Groundskeeper project
|
112
|
+
Everyone interacting in the Groundskeeper project's codebases, issue trackers,
|
107
113
|
chat rooms and mailing lists is expected to follow the
|
108
114
|
[code of conduct](https://github.com/NU-CBITS/groundskeeper/blob/master/CODE_OF_CONDUCT.md).
|
109
115
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Groundskeeper
|
6
|
+
# Bitbucket API wrapper
|
7
|
+
class Bitbucket
|
8
|
+
# Bitbucket API Error
|
9
|
+
class UnableToCreatePR < StandardError
|
10
|
+
def initialize(response)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
COMMAND = "curl"
|
16
|
+
BITBUCKET_USERNAME = "BITBUCKET_USERNAME"
|
17
|
+
BITBUCKET_APP_PASSWORD = "BITBUCKET_APP_PASSWORD"
|
18
|
+
URL = "https://api.bitbucket.org/2.0/repositories/"\
|
19
|
+
"isgmh-radd/%<repository>s/pullrequests"
|
20
|
+
CREATE_PR = <<~REQUEST.split.join(" ")
|
21
|
+
#{URL} -u %<username>s:%<password>s
|
22
|
+
--request POST
|
23
|
+
--header 'Content-Type: application/json'
|
24
|
+
--data
|
25
|
+
'{"title": "%<branch_name>s", "source": {"branch": {"name": "%<branch_name>s"}}}'
|
26
|
+
REQUEST
|
27
|
+
|
28
|
+
attr_reader :bitbucket
|
29
|
+
|
30
|
+
def self.build
|
31
|
+
new Executable.new(COMMAND)
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(bitbucket)
|
35
|
+
@bitbucket = bitbucket
|
36
|
+
end
|
37
|
+
|
38
|
+
# rubocop:disable Metrics/MethodLength
|
39
|
+
def create_pr(repository:, branch_name:)
|
40
|
+
response = bitbucket.execute(format(CREATE_PR,
|
41
|
+
username: ENV[BITBUCKET_USERNAME],
|
42
|
+
password: ENV[BITBUCKET_APP_PASSWORD],
|
43
|
+
repository: repository,
|
44
|
+
branch_name: branch_name))
|
45
|
+
pr_url = nil
|
46
|
+
begin
|
47
|
+
pr_url = JSON.parse(response)["links"]["html"]["href"]
|
48
|
+
rescue StandardError
|
49
|
+
raise UnableToCreatePR, response
|
50
|
+
end
|
51
|
+
|
52
|
+
open_url(pr_url)
|
53
|
+
end
|
54
|
+
# rubocop:enable Metrics/MethodLength
|
55
|
+
|
56
|
+
def credentials?
|
57
|
+
ENV[BITBUCKET_USERNAME].present? && ENV[BITBUCKET_APP_PASSWORD].present?
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# :nocov:
|
63
|
+
def open_url(url)
|
64
|
+
`open #{url}`
|
65
|
+
end
|
66
|
+
# :nocov:
|
67
|
+
end
|
68
|
+
end
|
@@ -26,6 +26,7 @@ module Groundskeeper
|
|
26
26
|
project = Project.build(repository.name)
|
27
27
|
deploy_url = "https://#{project.full_dns(stage)}"
|
28
28
|
website = Website.new(deploy_url)
|
29
|
+
bitbucket = Bitbucket.build
|
29
30
|
sentry = Sentry.build(
|
30
31
|
project_name: project.sentry_project,
|
31
32
|
version_prefix: repository.name
|
@@ -36,6 +37,7 @@ module Groundskeeper
|
|
36
37
|
new(
|
37
38
|
changelog: Changelog.build,
|
38
39
|
console: console,
|
40
|
+
bitbucket: bitbucket,
|
39
41
|
git: Git.build,
|
40
42
|
jira: Jira.build(project.jira_prefix),
|
41
43
|
project: project,
|
@@ -58,6 +60,7 @@ module Groundskeeper
|
|
58
60
|
def initialize(
|
59
61
|
changelog: nil,
|
60
62
|
console:,
|
63
|
+
bitbucket: nil,
|
61
64
|
git: nil,
|
62
65
|
jira: nil,
|
63
66
|
project: nil,
|
@@ -71,6 +74,7 @@ module Groundskeeper
|
|
71
74
|
)
|
72
75
|
@changelog = changelog
|
73
76
|
@console = console
|
77
|
+
@bitbucket = bitbucket
|
74
78
|
@git = git
|
75
79
|
@jira = jira
|
76
80
|
@project = project
|
@@ -107,11 +111,13 @@ module Groundskeeper
|
|
107
111
|
end
|
108
112
|
# rubocop:enable Metrics/AbcSize
|
109
113
|
|
110
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
114
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,
|
115
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
111
116
|
def release(options = {})
|
112
117
|
is_initial_release = !version_file.exists?
|
113
118
|
|
114
119
|
return missing_jira_credentials unless jira.credentials?
|
120
|
+
return missing_bitbucket_credentials unless bitbucket.credentials?
|
115
121
|
return unless check_groundskeeper_version
|
116
122
|
return unrecognized_version unless version_file.rails?
|
117
123
|
|
@@ -128,9 +134,10 @@ module Groundskeeper
|
|
128
134
|
create_jira_version
|
129
135
|
push
|
130
136
|
add_version_to_jira_issues unless is_initial_release
|
137
|
+
create_pr
|
131
138
|
end
|
132
139
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
133
|
-
# rubocop:enable Metrics/MethodLength
|
140
|
+
# rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity
|
134
141
|
|
135
142
|
# :nocov:
|
136
143
|
def predeploy(options = {})
|
@@ -171,7 +178,7 @@ module Groundskeeper
|
|
171
178
|
private
|
172
179
|
|
173
180
|
# collaborators
|
174
|
-
attr_reader :changelog, :console, :git, :jira, :project,
|
181
|
+
attr_reader :bitbucket, :changelog, :console, :git, :jira, :project,
|
175
182
|
:repository, :rubygems, :sentry, :slack, :ssh, :version_file,
|
176
183
|
:website
|
177
184
|
# state
|
@@ -277,6 +284,12 @@ module Groundskeeper
|
|
277
284
|
console.say("# added version to Jira issues #{issue_ids}", :green)
|
278
285
|
end
|
279
286
|
|
287
|
+
def create_pr
|
288
|
+
bitbucket.create_pr(
|
289
|
+
repository: repository.name, branch_name: new_branch_name
|
290
|
+
)
|
291
|
+
end
|
292
|
+
|
280
293
|
def next_jira_version_name
|
281
294
|
"#{repository.name} #{next_version}"
|
282
295
|
end
|
@@ -307,6 +320,13 @@ module Groundskeeper
|
|
307
320
|
)
|
308
321
|
end
|
309
322
|
|
323
|
+
def missing_bitbucket_credentials
|
324
|
+
console.say(
|
325
|
+
"Please configure your Bitbucket environment variables.",
|
326
|
+
:red
|
327
|
+
)
|
328
|
+
end
|
329
|
+
|
310
330
|
def missing_jira_credentials
|
311
331
|
console.say(
|
312
332
|
"Please configure your Jira environment variables.",
|
data/lib/groundskeeper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groundskeeper-bitcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BIT Core
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- certs/ericcf.pem
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jira-ruby
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- groundskeeper.gemspec
|
185
185
|
- lib/groundskeeper.rb
|
186
186
|
- lib/groundskeeper/application.rb
|
187
|
+
- lib/groundskeeper/bitbucket.rb
|
187
188
|
- lib/groundskeeper/changelog.rb
|
188
189
|
- lib/groundskeeper/commands.rb
|
189
190
|
- lib/groundskeeper/document.rb
|