lhj-tools 0.1.22 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/command/sync_pod_repo.rb +2 -2
- data/lib/lhj/helper/log_helper.rb +25 -8
- data/lib/lhj/helper/pgyer_config.rb +23 -5
- data/lib/lhj/helper/pgyer_helper.rb +7 -6
- data/lib/lhj/helper/pod_repo_config.rb +24 -0
- data/lib/lhj/helper/team_member_config.rb +20 -0
- data/lib/lhj/helper/trans_helper.rb +6 -1
- data/lib/lhj/jenkins/client.rb +837 -0
- data/lib/lhj/jenkins/exceptions.rb +226 -0
- data/lib/lhj/jenkins/job.rb +1933 -0
- data/lib/lhj/jenkins/urihelper.rb +21 -0
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +6 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f89a71391e6b1fde204d1f60f8de9f53c9c2fbef9719f71c389be011dc81525f
|
4
|
+
data.tar.gz: 45381e21de6e280cf07c28bc1beb45da1e81f736d3db455c46f74bd24f80e80c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ae36d611435d72feccbde3e516c692977cb4cbaa3a68dd3c7720ee7b58744bfb0da83d18f32a465e97abc75e6668d1a0a75a1b31e2d32973d18bc3cfcfb5210
|
7
|
+
data.tar.gz: e2bf9d372ba3f47fbabff55575930cbb5c56c2f987b0714185ccf01058e8b1ba50435326b07640768cc06e6060e9e9f6b3714a2ac397c2a3aa4d093c1854a9e1
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'lhj/config'
|
2
2
|
require 'highline'
|
3
|
+
require 'lhj/helper/pod_repo_config'
|
3
4
|
|
4
5
|
module Lhj
|
5
6
|
class Command
|
@@ -113,9 +114,8 @@ module Lhj
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def update_pod_repo
|
116
|
-
# pod repo push miguatech-aomi_ios-mlspecs *.podspec --sources=miguatech-aomi_ios-mlspecs,aliyun,trunk --allow-warnings --use-libraries --verbose
|
117
117
|
cmd = ['pod repo push']
|
118
|
-
pod_repo_name =
|
118
|
+
pod_repo_name = Lhj::PodRepoConfig.pod_repo_name
|
119
119
|
cmd << pod_repo_name
|
120
120
|
cmd << '*.podspec'
|
121
121
|
cmd << "--sources=#{pod_repo_name},aliyun,trunk"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'lhj/helper/team_member_config'
|
2
|
+
|
1
3
|
module Lhj
|
2
4
|
# log helper
|
3
5
|
class LogHelper
|
@@ -16,7 +18,8 @@ module Lhj
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def fetch_branch
|
19
|
-
Lhj::Actions.git_branch || ''
|
21
|
+
name = Lhj::Actions.git_branch || ''
|
22
|
+
name.split('/').last
|
20
23
|
end
|
21
24
|
|
22
25
|
def fetch_env(env)
|
@@ -33,12 +36,25 @@ module Lhj
|
|
33
36
|
def fetch_log
|
34
37
|
from = last_commit_hash
|
35
38
|
to = 'HEAD'
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
message = Lhj::Actions.git_log_between(' %an %ar - %s;', from, to, :exclude_merges, 'short', false)
|
40
|
+
handle_message(message)
|
41
|
+
end
|
42
|
+
|
43
|
+
def handle_message(m)
|
44
|
+
message = m
|
45
|
+
if !message.nil? && !message.empty?
|
46
|
+
message = message.gsub('seconds ', '秒')
|
47
|
+
message = message.gsub('minutes ', '分钟')
|
48
|
+
message = message.gsub('hours ', '小时')
|
49
|
+
message = message.gsub('days ', '天')
|
50
|
+
message = message.gsub('ago ', '前')
|
51
|
+
Lhj::TeamMemberConfig.config.each do |key, value|
|
52
|
+
message = message.gsub(key, value) if message =~ /#{key}/
|
53
|
+
end
|
54
|
+
else
|
55
|
+
message = '此次打包没代码更新'
|
56
|
+
end
|
57
|
+
message
|
42
58
|
end
|
43
59
|
|
44
60
|
def save_last_commit_hash
|
@@ -56,7 +72,8 @@ module Lhj
|
|
56
72
|
end
|
57
73
|
|
58
74
|
def last_commit_file
|
59
|
-
|
75
|
+
branch_name = @branch.gsub(%r{/}, '')
|
76
|
+
File.join(Lhj::Config.instance.home_dir, ".#{@env}_#{branch_name}_last_commit")
|
60
77
|
end
|
61
78
|
|
62
79
|
def render_template
|
@@ -16,15 +16,33 @@ module Lhj
|
|
16
16
|
@yaml ||= YAML.load_file(config_file)
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.api_key
|
20
|
-
|
19
|
+
def self.api_key(env = :uat)
|
20
|
+
case env
|
21
|
+
when :release
|
22
|
+
config['release_api_key']
|
23
|
+
when :gray
|
24
|
+
config['gray_api_key']
|
25
|
+
when :uat
|
26
|
+
config['uat_api_key']
|
27
|
+
else
|
28
|
+
config['api_key']
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
|
-
def self.user_key
|
24
|
-
|
32
|
+
def self.user_key(env = :uat)
|
33
|
+
case env
|
34
|
+
when :release
|
35
|
+
config['release_user_key']
|
36
|
+
when :gray
|
37
|
+
config['gray_user_key']
|
38
|
+
when :uat
|
39
|
+
config['uat_user_key']
|
40
|
+
else
|
41
|
+
config['user_key']
|
42
|
+
end
|
25
43
|
end
|
26
44
|
|
27
|
-
def self.password
|
45
|
+
def self.password(env = :uat)
|
28
46
|
config['password']
|
29
47
|
end
|
30
48
|
end
|
@@ -13,10 +13,10 @@ module Lhj
|
|
13
13
|
|
14
14
|
attr_reader :api_key, :user_key, :password, :result
|
15
15
|
|
16
|
-
def initialize
|
17
|
-
@api_key = Lhj::PgyerConfig.api_key
|
18
|
-
@user_key = Lhj::PgyerConfig.user_key
|
19
|
-
@password = Lhj::PgyerConfig.password
|
16
|
+
def initialize(env = :uat)
|
17
|
+
@api_key = Lhj::PgyerConfig.api_key(env)
|
18
|
+
@user_key = Lhj::PgyerConfig.user_key(env)
|
19
|
+
@password = Lhj::PgyerConfig.password(env)
|
20
20
|
@result = { 'data' => {} }
|
21
21
|
end
|
22
22
|
|
@@ -39,7 +39,7 @@ module Lhj
|
|
39
39
|
def upload_file(file, des)
|
40
40
|
|
41
41
|
update_description = @result[:update_description]
|
42
|
-
update_description =
|
42
|
+
update_description = '' if update_description.nil?
|
43
43
|
params = {
|
44
44
|
'_api_key' => @api_key,
|
45
45
|
'uKey' => @user_key,
|
@@ -49,10 +49,11 @@ module Lhj
|
|
49
49
|
'file' => Faraday::UploadIO.new(file, 'application/octet-stream')
|
50
50
|
}
|
51
51
|
begin
|
52
|
-
puts 'begin upload'
|
52
|
+
puts 'begin upload...'
|
53
53
|
response = http_client.post API_HOST, params
|
54
54
|
@result = response.body
|
55
55
|
puts @result
|
56
|
+
puts 'upload success'
|
56
57
|
if @result['data'] && @result['data']['appUpdateDescription']
|
57
58
|
@result['data']['appUpdateDescription'] = Lhj::TbHelper.trans_tb(@result['data']['appUpdateDescription'])
|
58
59
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# pod repo config
|
7
|
+
class PodRepoConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'pod_repo_config.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.pod_repo_name
|
20
|
+
config['pod_repo_name']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# team member config
|
7
|
+
class TeamMemberConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'team_member.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'lhj/config'
|
2
|
+
require_relative 'oss_config'
|
2
3
|
|
3
4
|
module Lhj
|
4
5
|
class Trans
|
@@ -18,9 +19,13 @@ module Lhj
|
|
18
19
|
contents.to_hash
|
19
20
|
end
|
20
21
|
|
22
|
+
def down_load_path
|
23
|
+
"http://#{Lhj::OSSConfig.oss_bucket}.#{Lhj::OSSConfig.oss_endpoint}/zh2hant.yml"
|
24
|
+
end
|
25
|
+
|
21
26
|
def down_load_yaml
|
22
27
|
require 'open-uri'
|
23
|
-
URI.open(
|
28
|
+
URI.open(down_load_path) do |i|
|
24
29
|
File.open(yaml_file, 'w+') do |f|
|
25
30
|
f.write(i.read)
|
26
31
|
end
|