CiHelper 2.0.1 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ci_helper/bitbucket_procedure.rb +1 -0
- data/lib/ci_helper/constants.rb +2 -0
- data/lib/ci_helper/functions/base.rb +1 -1
- data/lib/ci_helper/functions/jenkin.rb +11 -3
- data/lib/ci_helper/functions/pull_request.rb +24 -3
- data/lib/ci_helper/functions/redmine.rb +34 -15
- data/lib/ci_helper/main_process.rb +7 -0
- data/lib/ci_helper/user_command_line_interface.rb +13 -0
- data/lib/ci_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aad5fddb4944394ae717fc8eb203d5ef7c390270
|
4
|
+
data.tar.gz: b321528c4c31345d7a054bf877a01342c5595f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8abec7a049dd5ecaeb052b5748cfcf6b68c89c3004143da5fa09e103b63e7f015eca5b5963ec5eb172937304a692b19553176b43cd82a2f0b914782ad6452c89
|
7
|
+
data.tar.gz: 5ec021b00aef2415fd9fc7fb8e72d0baf83f622096b3535458c1b39196f2731c7ea1bb7f95e1fa2c5ebde6cbb3361823a28f8f4f5d6e9fbecdcec1d21fa8fbdc
|
@@ -63,6 +63,7 @@ module CiHelper
|
|
63
63
|
issue_numbers.size > 1
|
64
64
|
end
|
65
65
|
|
66
|
+
# transform the user input branch name t3001 t3001_reopen or t3001_t3002_t3003 to [3001], [3001] or [3001,3002,3003]
|
66
67
|
def issue_numbers
|
67
68
|
branch_name.split('_').each { |name| name.delete!('t') }.delete_if { |name| name.to_i.zero?}
|
68
69
|
end
|
data/lib/ci_helper/constants.rb
CHANGED
@@ -8,7 +8,7 @@ module CiHelper
|
|
8
8
|
|
9
9
|
def initialize(config)
|
10
10
|
@user_cli = CiHelper::UserCommandLineInterface.new
|
11
|
-
|
11
|
+
@config = config
|
12
12
|
|
13
13
|
@issue_monitor = IssueMonitor.new(config.ci_ac, config.ci_pass)
|
14
14
|
@bit_bucket_client = BitBucketProcedure.new(config.bit_ac, config.bit_pass)
|
@@ -19,14 +19,13 @@ module CiHelper
|
|
19
19
|
if issue_monitor.success?
|
20
20
|
print_console_link
|
21
21
|
start_pull_request_function
|
22
|
-
|
23
|
-
# update_issue
|
22
|
+
update_issue_status if user_cli.update_issue?
|
24
23
|
else
|
25
24
|
print_fails
|
26
25
|
print_console_link
|
27
26
|
if user_cli.force_create_pull_request?
|
28
27
|
start_pull_request_function
|
29
|
-
|
28
|
+
update_issue_status if user_cli.update_issue?
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -51,6 +50,15 @@ module CiHelper
|
|
51
50
|
puts "Console link: #{result.console_link}"
|
52
51
|
end
|
53
52
|
|
53
|
+
def update_issue_status
|
54
|
+
redmine_updater = CiHelper::Functions::Redmine.new(config)
|
55
|
+
redmine_updater.issue_numbers = bit_bucket_client.issue_numbers
|
56
|
+
redmine_updater.status = CiHelper::RESOLVED
|
57
|
+
redmine_updater.text_box = "pull request : #{CiHelper::BITBUCKET_DOMAIN}#{bit_bucket_client.pull_request_page.link_with(class: 'execute').href} \n"
|
58
|
+
redmine_updater.text_box += "\n CiHelper :#{CiHelper::VERSION}"
|
59
|
+
redmine_updater.run
|
60
|
+
end
|
61
|
+
|
54
62
|
def result
|
55
63
|
@result ||= issue_monitor.content
|
56
64
|
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'ci_helper/constants'
|
2
|
+
require 'ci_helper/version'
|
1
3
|
module CiHelper
|
2
4
|
module Functions
|
3
5
|
class PullRequest < Base
|
6
|
+
# This class is responsible for creating pull request for user
|
4
7
|
|
5
8
|
attr_reader :branch_name
|
6
9
|
|
@@ -15,6 +18,18 @@ module CiHelper
|
|
15
18
|
user_cli.print_target(redmine_client.issue.target_version)
|
16
19
|
end
|
17
20
|
|
21
|
+
create_pull_request
|
22
|
+
update_issue_status
|
23
|
+
end
|
24
|
+
|
25
|
+
# API for outside to set the branch name, normally it accept the params from jenkin function
|
26
|
+
def branch_name=(name)
|
27
|
+
@branch_name = name
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def create_pull_request
|
18
33
|
bit_bucket_client.add_destination(user_cli.get_destination)
|
19
34
|
bit_bucket_client.add_user_description(user_cli.get_more_info)
|
20
35
|
bit_bucket_client.reviewers = user_cli.get_reviewers
|
@@ -28,10 +43,16 @@ module CiHelper
|
|
28
43
|
puts "this is your pull request page : #{CiHelper::BITBUCKET_DOMAIN}#{bit_bucket_client.pull_request_page.link_with(class: 'execute').href}"
|
29
44
|
end
|
30
45
|
|
31
|
-
def
|
32
|
-
|
46
|
+
def update_issue_status
|
47
|
+
if user_cli.update_issue?
|
48
|
+
redmine_updater = CiHelper::Functions::Redmine.new(config)
|
49
|
+
redmine_updater.issue_numbers = bit_bucket_client.issue_numbers
|
50
|
+
redmine_updater.status = CiHelper::UTPASSED
|
51
|
+
redmine_updater.text_box = "pull request : #{CiHelper::BITBUCKET_DOMAIN}#{bit_bucket_client.pull_request_page.link_with(class: 'execute').href} \n"
|
52
|
+
redmine_updater.text_box += "\n CiHelper :#{CiHelper::VERSION}"
|
53
|
+
redmine_updater.run
|
54
|
+
end
|
33
55
|
end
|
34
|
-
|
35
56
|
end
|
36
57
|
end
|
37
58
|
end
|
@@ -1,32 +1,51 @@
|
|
1
1
|
module CiHelper
|
2
2
|
module Functions
|
3
3
|
class Redmine < Base
|
4
|
+
attr_reader :status, :text_box
|
5
|
+
|
6
|
+
# This class responsible for update issue in redmine for one issue or multiple issue
|
4
7
|
def run
|
5
|
-
@issue_numbers = user_cli.get_issue_numbers
|
6
|
-
|
7
|
-
|
8
|
-
# TODO: handle multiple issue situation
|
9
|
-
# This feature need to wait the issue to handle the status which is not exists
|
10
|
-
# automaticly change the status for user
|
11
|
-
#
|
12
|
-
puts 'sorry now we can not handle this situation '
|
13
|
-
else
|
14
|
-
redmine_client.issue_no = @issue_numbers
|
8
|
+
@issue_numbers = issue_numbers || user_cli.get_issue_numbers
|
9
|
+
|
10
|
+
issue_numbers.each do |issue_number|
|
15
11
|
redmine_client.issue_setting do |config|
|
16
12
|
|
13
|
+
redmine_client.issue_no = issue_number
|
14
|
+
puts "issue number : #{issue_number}"
|
15
|
+
|
17
16
|
redmine_client.issue.print_all_status
|
18
|
-
config.status
|
19
|
-
config.text_box
|
17
|
+
config.status = status || user_cli.get_status
|
18
|
+
config.text_box = text_box || user_cli.get_more_info
|
19
|
+
redmine_client.issue.submit
|
20
20
|
end
|
21
|
-
|
22
|
-
redmine_client.issue.submit
|
23
21
|
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def status=(value)
|
26
|
+
@status = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def text_box=(value)
|
30
|
+
@text_box = value
|
31
|
+
end
|
32
|
+
|
33
|
+
def issue_numbers=(value)
|
34
|
+
@issue_numbers = value
|
24
35
|
end
|
25
36
|
|
26
37
|
private
|
27
38
|
|
28
39
|
def multiple_issues?
|
29
|
-
|
40
|
+
issue_numbers.size > 1
|
41
|
+
end
|
42
|
+
|
43
|
+
def issue_numbers
|
44
|
+
if @issue_numbers.is_a? String
|
45
|
+
@issue_numbers.split(' ')
|
46
|
+
else
|
47
|
+
@issue_numbers
|
48
|
+
end
|
30
49
|
end
|
31
50
|
end
|
32
51
|
end
|
@@ -21,7 +21,9 @@ module CiHelper
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run
|
24
|
+
|
24
25
|
while true
|
26
|
+
begin
|
25
27
|
@option = user_cli.get_user_choose
|
26
28
|
|
27
29
|
if ci_monitor?
|
@@ -33,6 +35,11 @@ module CiHelper
|
|
33
35
|
else
|
34
36
|
puts 'Please dont act like a monkey'
|
35
37
|
end
|
38
|
+
rescue => e
|
39
|
+
puts 'You may enter wrong ticket, branch name or face a internet problem'
|
40
|
+
puts e.message
|
41
|
+
puts "If you think is a bug please go to create a issue for me #{CiHelper::BUG_REPORT_URL}"
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
|
@@ -46,6 +46,15 @@ module CiHelper
|
|
46
46
|
user_answer?
|
47
47
|
end
|
48
48
|
|
49
|
+
def update_issue?
|
50
|
+
self.user_answer = get_user_input do
|
51
|
+
puts update_issue_question
|
52
|
+
puts 'y/n'
|
53
|
+
end
|
54
|
+
|
55
|
+
user_answer?
|
56
|
+
end
|
57
|
+
|
49
58
|
def user_answer?
|
50
59
|
user_answer == 'y' || user_answer == 'Y'
|
51
60
|
end
|
@@ -192,5 +201,9 @@ please input 1, 2 or 3"
|
|
192
201
|
def issue_number_question
|
193
202
|
'please input your ticket number you want to update'
|
194
203
|
end
|
204
|
+
|
205
|
+
def update_issue_question
|
206
|
+
'Do you want me update the issue for you to ut passed ?'
|
207
|
+
end
|
195
208
|
end
|
196
209
|
end
|
data/lib/ci_helper/version.rb
CHANGED