tuya-ci-core 0.1.2 → 0.2.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/bin/tuyacicore +0 -0
- data/lib/tuya/ci/core/config/config_gitlab.rb +2 -0
- data/lib/tuya/ci/core/config/config_modules.rb +109 -0
- data/lib/tuya/ci/core/config/odm_config_modules.rb +56 -0
- data/lib/tuya/ci/core/config.rb +21 -0
- data/lib/tuya/ci/core/dependencies/node/podfile_lock_analyse.rb +119 -0
- data/lib/tuya/ci/core/dependencies/node/podfile_lock_node.rb +39 -0
- data/lib/tuya/ci/core/dependencies/podfile_lock.rb +39 -0
- data/lib/tuya/ci/core/dependencies.rb +40 -0
- data/lib/tuya/ci/core/download.rb +11 -0
- data/lib/tuya/ci/core/executable.rb +2 -0
- data/lib/tuya/ci/core/git/gitlab/gitlab_odm.rb +143 -0
- data/lib/tuya/ci/core/git.rb +98 -33
- data/lib/tuya/ci/core/language_update.rb +17 -0
- data/lib/tuya/ci/core/odm_build.rb +246 -0
- data/lib/tuya/ci/core/podfile.rb +21 -3
- data/lib/tuya/ci/core/podspec.rb +39 -9
- data/lib/tuya/ci/core/repo_release_ci.rb +44 -0
- data/lib/tuya/ci/core/spec/odm/spec_odm.rb +48 -0
- data/lib/tuya/ci/core/spec/release/repo_release.rb +67 -0
- data/lib/tuya/ci/core/spec/release/repo_release_git.rb +27 -0
- data/lib/tuya/ci/core/template/template_configurator.rb +54 -15
- data/lib/tuya/ci/core/template.rb +10 -4
- data/lib/tuya/ci/core/util/file.rb +39 -0
- data/lib/tuya/ci/core/version.rb +1 -1
- data/lib/tuya/ci/core.rb +28 -2
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c318fd664d9d6a7dd4f535615ec6172e638c3a2
|
4
|
+
data.tar.gz: 8e1005fc9d1ee413438a0ddd0483d066e26cdc82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7e3dd4eb3ec40f61eb7d2669a5ccca253783d054c50fe87de7c33564beb52444b5af009fc444dbc930ccd8e200e93b60e79d986ee3c893115cc9b4afd3f8621
|
7
|
+
data.tar.gz: 7b8be9fa7634b4a53cd0c73dc5ef0bb31312d0fef7080135503565262658f849f11a1cf455b3ef928d0aa1754048bf61662fd726f75bbbfa10c0d5080373348a
|
data/bin/tuyacicore
CHANGED
File without changes
|
@@ -0,0 +1,109 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
+
module TYCiCore
|
3
|
+
class ConfigModules
|
4
|
+
|
5
|
+
attr_accessor :config_path, :advance_fields, :pod_path
|
6
|
+
|
7
|
+
def initialize(config_path="./config_modules.json", advance_fields="{}", pod_path="./Pods/")
|
8
|
+
@config_path = config_path
|
9
|
+
@advance_fields = advance_fields
|
10
|
+
@pod_path = pod_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def config_hash
|
14
|
+
content = File.read @config_path
|
15
|
+
hash = JSON content
|
16
|
+
hash
|
17
|
+
end
|
18
|
+
|
19
|
+
def modules_in_pods
|
20
|
+
result = []
|
21
|
+
pod_directories = Dir["#{@pod_path}*"].reject{|o| not File.directory?(o)}
|
22
|
+
pod_directories.each do |folder|
|
23
|
+
name = folder.gsub(/\s+/,'').split('/')[-1]
|
24
|
+
if module?(name) && name!="Target Support Files"
|
25
|
+
result.push(name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
result
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup_modules
|
32
|
+
|
33
|
+
puts "Setup #{@config_path} at #{@pod_path}".green
|
34
|
+
|
35
|
+
modules = modules_in_pods
|
36
|
+
|
37
|
+
advance_json = JSON.parse(@advance_fields)
|
38
|
+
advance_json["modules"] = modules
|
39
|
+
|
40
|
+
advance_json_pretty = JSON.pretty_generate(advance_json)
|
41
|
+
fh = File.new(@config_path, "w")
|
42
|
+
fh.puts advance_json_pretty
|
43
|
+
fh.close
|
44
|
+
end
|
45
|
+
|
46
|
+
def module?(name)
|
47
|
+
# find_command = "find #{pod_path} -iname #{name}Impl.h"
|
48
|
+
# # puts("find_command is #{find_command}")
|
49
|
+
# find_command_result = Action.sh find_command
|
50
|
+
# # puts("find_command_result is #{find_command_result}")
|
51
|
+
# if find_command_result.length > 0
|
52
|
+
# return true
|
53
|
+
# else
|
54
|
+
# return module_lib?(name)
|
55
|
+
# end
|
56
|
+
commands = %W(#{pod_path} -iname #{name}Impl.h)
|
57
|
+
result = EXE.exe('find', commands)
|
58
|
+
|
59
|
+
if result.length > 0
|
60
|
+
true
|
61
|
+
else
|
62
|
+
module_lib?(name)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def module_lib?(name)
|
67
|
+
|
68
|
+
puts "Name is #{name}".green
|
69
|
+
|
70
|
+
lib_path = "#{@pod_path}#{name}/#{name}*/lib#{name}.a"
|
71
|
+
|
72
|
+
puts "File_path is #{lib_path}".yellow
|
73
|
+
|
74
|
+
libs_path_result = Dir.glob(lib_path)
|
75
|
+
|
76
|
+
puts("The path is#{libs_path_result}")
|
77
|
+
|
78
|
+
if libs_path_result.length > 0
|
79
|
+
|
80
|
+
file_path = libs_path_result[0]
|
81
|
+
# find_command = "nm -gU #{file_path} | grep '_OBJC_CLASS_\\$_#{name}Impl'"
|
82
|
+
#
|
83
|
+
exists_impl = true
|
84
|
+
# find_command_result = Action.sh(
|
85
|
+
# find_command,
|
86
|
+
# error_callback: ->(result) {
|
87
|
+
# exists_impl = false
|
88
|
+
# }
|
89
|
+
# )
|
90
|
+
|
91
|
+
# TODO exist?
|
92
|
+
commands = %W(-gU #{file_path} | grep '_OBJC_CLASS_\\$_#{name}Impl')
|
93
|
+
|
94
|
+
find_result = EXE.exe('nm', commands)
|
95
|
+
|
96
|
+
if exists_impl && !find_result.empty?
|
97
|
+
puts "Static lib #{name} has #{name}mpl".green
|
98
|
+
true
|
99
|
+
else
|
100
|
+
puts "Static lib #{name} can not find #{name}mpl".red
|
101
|
+
false
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
false
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'tuya/ci/core/config/config_modules'
|
2
|
+
|
3
|
+
module TYCiCore
|
4
|
+
class ODMConfigModules < ConfigModules
|
5
|
+
|
6
|
+
attr_accessor :content
|
7
|
+
|
8
|
+
def initialize(config_path="./config_modules.json", pod_path="./Pods/")
|
9
|
+
@config_path = config_path
|
10
|
+
@pod_path = pod_path
|
11
|
+
@content = config_hash
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_mix(key, value)
|
15
|
+
mix = @content["mixMap"]
|
16
|
+
if mix.nil? || mix.empty?
|
17
|
+
mix = Hash[key => value]
|
18
|
+
else
|
19
|
+
mix[key]=value
|
20
|
+
end
|
21
|
+
@content["mixMap"]=mix
|
22
|
+
end
|
23
|
+
|
24
|
+
# def add_mix(mixHash)
|
25
|
+
# mix = @content["mixMap"]
|
26
|
+
# if mix.nil? || mix.empty?
|
27
|
+
# mix = mixHash
|
28
|
+
# else
|
29
|
+
# mix = mix.merge(mixHash)
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
|
33
|
+
def remove_mix(key)
|
34
|
+
@content["mixMap"].delete(key)
|
35
|
+
end
|
36
|
+
|
37
|
+
def update_config(key, value)
|
38
|
+
@content[key]=value
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_modules # 根据 pod目录生成 modules
|
42
|
+
puts "ODM Setup #{@config_path} at #{@pod_path}".green
|
43
|
+
|
44
|
+
modules = modules_in_pods
|
45
|
+
|
46
|
+
@content["modules"] = modules
|
47
|
+
end
|
48
|
+
|
49
|
+
def save(target=@config_path)
|
50
|
+
file_content = JSON.pretty_generate(@content)
|
51
|
+
fh = File.new(target, "w")
|
52
|
+
fh << file_content
|
53
|
+
fh.close
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
class Config
|
3
|
+
def initialize(path)
|
4
|
+
raise "Can not find config at : #{path}" unless File.exist? path
|
5
|
+
@content = File.read path
|
6
|
+
@content_json = JSON @content
|
7
|
+
end
|
8
|
+
|
9
|
+
def value(key)
|
10
|
+
eval("@content_json" << key.split('.').map { |i| "[\"" + i + "\"]" }.join)
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing(name)
|
14
|
+
if @content_json.has_key? name.to_s
|
15
|
+
@content_json[name.to_s]
|
16
|
+
else
|
17
|
+
super.method_missing name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
class TYPodAnalyse
|
3
|
+
attr_accessor :pods_hash, :pod_nodes_hash, :podfile_lock
|
4
|
+
def initialize(podfile_lock)
|
5
|
+
@pods_hash = Hash.new
|
6
|
+
@pod_nodes_hash = Hash.new
|
7
|
+
@podfile_lock = podfile_lock
|
8
|
+
podfile_lock.all_pods.each do |pod|
|
9
|
+
pod_item = TYPodItem.new pod
|
10
|
+
pod_item.dependency_list = @podfile_lock.pods[pod]
|
11
|
+
@pods_hash[pod] = pod_item
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def sorted_pods
|
16
|
+
trees
|
17
|
+
dep_tree
|
18
|
+
diplomatic_pods
|
19
|
+
end
|
20
|
+
|
21
|
+
def trees
|
22
|
+
@podfile_lock.all_pods.each do |pod_name|
|
23
|
+
pod_item = @pods_hash[pod_name]
|
24
|
+
unless pod_item.dependency
|
25
|
+
@pod_nodes_hash[pod_name] = tree_build TYPodNode.new, pod_item
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def tree_build(root_node, root_item)
|
31
|
+
root_node.add_pod_item root_item
|
32
|
+
root_item.dependency = true
|
33
|
+
if root_item.dependency_list
|
34
|
+
root_item.dependency_list.each do |item|
|
35
|
+
child_item = @pods_hash[item]
|
36
|
+
if child_item
|
37
|
+
child_node = @pod_nodes_hash[child_item.name]
|
38
|
+
if child_node
|
39
|
+
unless child_node.parent
|
40
|
+
@pod_nodes_hash.delete child_node.pod_item.name
|
41
|
+
root_node.join_node child_node
|
42
|
+
end
|
43
|
+
else
|
44
|
+
child_node = TYPodNode.new
|
45
|
+
root_node.join_node tree_build(child_node, child_item)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
root_node
|
51
|
+
end
|
52
|
+
|
53
|
+
def dep_tree
|
54
|
+
@pods_hash.keys.each do |name|
|
55
|
+
child_node = @pod_nodes_hash[name]
|
56
|
+
dep_node child_node
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def dep_node(node)
|
61
|
+
if !node || !node.nodes || node.nodes.size == 0
|
62
|
+
return 0
|
63
|
+
end
|
64
|
+
dep = []
|
65
|
+
node.nodes.keys.each do |name|
|
66
|
+
child_node = node.nodes[name]
|
67
|
+
dep.push((dep_node child_node) + 1)
|
68
|
+
end
|
69
|
+
max_dep = dep.max
|
70
|
+
node.node_dep = max_dep
|
71
|
+
node.node_dep
|
72
|
+
end
|
73
|
+
|
74
|
+
def sort_nodes
|
75
|
+
@pod_nodes_hash.sort_by do |k, v|
|
76
|
+
v.node_dep
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def diplomatic_pods
|
81
|
+
sort_nodes
|
82
|
+
pods_ = []
|
83
|
+
@pod_nodes_hash.keys.each do |key|
|
84
|
+
pods_ << (level_order_node @pod_nodes_hash[key])
|
85
|
+
end
|
86
|
+
pods_hash = Hash.new
|
87
|
+
pods_.each do |pods|
|
88
|
+
order = pods_hash[pods.size]
|
89
|
+
if order
|
90
|
+
order.pods = order.pods + pods
|
91
|
+
else
|
92
|
+
pods_hash[pods.size] = TYPodOrder.new pods.size, pods
|
93
|
+
end
|
94
|
+
end
|
95
|
+
pods_keys_sort = pods_hash.keys.sort.reverse
|
96
|
+
result = []
|
97
|
+
pods_keys_sort.each do |key|
|
98
|
+
pods = pods_hash[key].pods
|
99
|
+
result += pods
|
100
|
+
end
|
101
|
+
result.uniq
|
102
|
+
end
|
103
|
+
|
104
|
+
def level_order_node(node)
|
105
|
+
result = []
|
106
|
+
queue = []
|
107
|
+
queue.push node
|
108
|
+
while queue.size > 0 do
|
109
|
+
target_node = queue[0]
|
110
|
+
queue.delete_at 0
|
111
|
+
result.insert 0,target_node.pod_item.name
|
112
|
+
target_node.nodes.keys.each do |key_node|
|
113
|
+
queue.push target_node.nodes[key_node] if target_node.nodes[key_node]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
result.uniq
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
class TYPodNode
|
3
|
+
|
4
|
+
attr_accessor :node_dep, :parent, :nodes, :pod_item
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@node_dep = 0
|
8
|
+
@parent = ''
|
9
|
+
@nodes = Hash.new
|
10
|
+
@pod_item = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def join_node(node)
|
14
|
+
node.parent = @pod_item.name
|
15
|
+
nodes[node.pod_item.name] = node
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_pod_item(item)
|
19
|
+
@pod_item = item if item
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class TYPodItem
|
24
|
+
attr_accessor :name, :dependency, :dependency_list
|
25
|
+
def initialize(name)
|
26
|
+
@name = name
|
27
|
+
@dependency = false
|
28
|
+
@dependency_list = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class TYPodOrder
|
33
|
+
attr_accessor :pods, :group
|
34
|
+
def initialize(order, pods)
|
35
|
+
@group = order
|
36
|
+
@pods = pods
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
|
3
|
+
class TYPodFileLock
|
4
|
+
attr_accessor :all_pods, :pods
|
5
|
+
|
6
|
+
def initialize(text)
|
7
|
+
all_pods_temp = text.scan /^\s+(\w+-*\w+): [0-9a-zA-Z]*$/
|
8
|
+
|
9
|
+
@all_pods = []
|
10
|
+
|
11
|
+
all_pods_temp.each do |pod|
|
12
|
+
@all_pods << pod[0]
|
13
|
+
end
|
14
|
+
|
15
|
+
@pods = Hash.new
|
16
|
+
@all_pods.each do |pod|
|
17
|
+
pod_dependencies = []
|
18
|
+
pod_scan = text.scan /^\s{2}-\s+#{pod}\s+.*:((\n\s{4}-\s+.*)*)/
|
19
|
+
pod_scan.each do |pod_item|
|
20
|
+
if pod_item.size > 0
|
21
|
+
item = pod_item[0]
|
22
|
+
item.gsub!(/\n/, '')
|
23
|
+
item.split(' - ').each do |item_content|
|
24
|
+
if item_content != ""
|
25
|
+
item_content_clean = item_content.gsub!(/\s\(.*\s.*\)/, '')
|
26
|
+
if item_content_clean
|
27
|
+
pod_dependencies.push item_content_clean
|
28
|
+
else
|
29
|
+
pod_dependencies.push item_content
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
@pods[pod] = pod_dependencies if pod_dependencies.size > 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
class TYDependencies
|
3
|
+
|
4
|
+
attr_accessor :path, :content
|
5
|
+
|
6
|
+
def initialize(path)
|
7
|
+
@path = path
|
8
|
+
@content = ''
|
9
|
+
end
|
10
|
+
|
11
|
+
def sort_pods(pods)
|
12
|
+
if File.exist? @path
|
13
|
+
lock_pods = analysis
|
14
|
+
pods_hash = Hash.new
|
15
|
+
pods.each do |pod|
|
16
|
+
pods_hash[pod["name"]] = pod
|
17
|
+
end
|
18
|
+
result = []
|
19
|
+
lock_pods.each do |lock_pod|
|
20
|
+
if pods_hash.keys.include? lock_pod
|
21
|
+
result.push pods_hash[lock_pod]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
result
|
25
|
+
else
|
26
|
+
puts "Can not find file: #{@path}".red
|
27
|
+
pods
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def analysis
|
32
|
+
content = File.read @path
|
33
|
+
|
34
|
+
podfile_lock = TYPodFileLock.new content
|
35
|
+
|
36
|
+
analysis = TYPodAnalyse.new podfile_lock
|
37
|
+
analysis.sorted_pods
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
class TYDownload
|
3
|
+
def self.download(url, name, path='./')
|
4
|
+
puts "Start download : #{url}"
|
5
|
+
data=open(url){|f|f.read}
|
6
|
+
puts "Saving #{path}#{name}"
|
7
|
+
open("#{path}#{name}","wb"){|f|f.write(data)}
|
8
|
+
FileUtils.pwd << "/#{name}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
class GitlabODM
|
3
|
+
|
4
|
+
attr_accessor :config, :name, :path, :visibility
|
5
|
+
|
6
|
+
def initialize (config, path, visibility, username, password, email)
|
7
|
+
@config = config
|
8
|
+
@path = path
|
9
|
+
@visibility = visibility
|
10
|
+
|
11
|
+
@username = username
|
12
|
+
@password = password
|
13
|
+
@email = email
|
14
|
+
|
15
|
+
@group_id = ""
|
16
|
+
@user_id = ""
|
17
|
+
|
18
|
+
@hook_project_ios = ""
|
19
|
+
@hook_project_android = ""
|
20
|
+
@hook_project_id_ios = ""
|
21
|
+
@hook_project_id_android = ""
|
22
|
+
@hook_project_url_ios = ""
|
23
|
+
@hook_project_url_android = ""
|
24
|
+
end
|
25
|
+
|
26
|
+
def odm
|
27
|
+
|
28
|
+
if create_group
|
29
|
+
if create_user
|
30
|
+
if add_user_group
|
31
|
+
add_project_group
|
32
|
+
get_project_id
|
33
|
+
add_project_hook @hook_project_id_ios, @config.hook_ios
|
34
|
+
add_project_hook @hook_project_id_android, @config.hook_android
|
35
|
+
|
36
|
+
TYCiCore::Git.git_delete_temp_path @hook_project_ios
|
37
|
+
TYCiCore::Git.git_delete_temp_path @hook_project_android
|
38
|
+
|
39
|
+
puts "odm create gitlab group json is:[start:success:end]".green
|
40
|
+
else
|
41
|
+
puts 'ODM add user to group failed'.red
|
42
|
+
puts "odm create gitlab group json is:[start:failed:end]".red
|
43
|
+
end
|
44
|
+
else
|
45
|
+
puts 'ODM create user failed'.red
|
46
|
+
puts "odm create gitlab group json is:[start:failed:end]".red
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts 'ODM create group failed'.red
|
51
|
+
puts "odm create gitlab group json is:[start:failed:end]".red
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_group
|
58
|
+
puts 'ODM create group ...'.green
|
59
|
+
result = `curl #{@config.host}/api/#{@config.version}/groups -X POST -d "private_token=#{@config.private_token}&name=#{@path}&path=#{@path}&visibility=#{@visibility}"`
|
60
|
+
json = JSON result
|
61
|
+
@group_id = json["id"]
|
62
|
+
|
63
|
+
result_bool = not_empty?(json["name"]) && not_empty?(json["web_url"])
|
64
|
+
puts json unless result_bool
|
65
|
+
result_bool
|
66
|
+
end
|
67
|
+
|
68
|
+
def create_user
|
69
|
+
puts 'ODM create user ...'.green
|
70
|
+
result = `curl #{@config.host}/api/v4/users?private_token=#{@config.private_token} -X POST -d "name=#{@username}&username=#{@username}&password=#{@password}&email=#{@email}&skip_confirmation=true"`
|
71
|
+
|
72
|
+
json = JSON result
|
73
|
+
@user_id = json["id"]
|
74
|
+
|
75
|
+
result_bool = not_empty?(json["state"]) && not_empty?(json["created_at"])
|
76
|
+
puts json unless result_bool
|
77
|
+
result_bool
|
78
|
+
end
|
79
|
+
|
80
|
+
def add_user_group
|
81
|
+
puts 'ODM add user to group ...'.green
|
82
|
+
result = `curl #{@config.host}/api/v4/groups/#{@group_id}/members?private_token=#{@config.private_token} -X POST -d "id=#{@group_id}&user_id=#{@user_id}&access_level=50"`
|
83
|
+
json = JSON result
|
84
|
+
|
85
|
+
result_bool = not_empty?(json["state"]) && not_empty?(json["username"])
|
86
|
+
puts json unless result_bool
|
87
|
+
result_bool
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_project_group
|
91
|
+
|
92
|
+
@hook_project_android = "#{path}Repository"
|
93
|
+
@hook_project_ios = "#{path}Specs"
|
94
|
+
|
95
|
+
@hook_project_url_ios = "#{@config.host}/#{path}/#{@hook_project_ios}.git"
|
96
|
+
@hook_project_url_android = "#{@config.host}/#{path}/#{@hook_project_android}.git"
|
97
|
+
|
98
|
+
TYCiCore::Git.git_create_empty_repos @hook_project_ios, @hook_project_url_ios
|
99
|
+
TYCiCore::Git.git_create_empty_repos @hook_project_android, @hook_project_url_android
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_project_id
|
103
|
+
puts 'ODM get project id in group'.green
|
104
|
+
|
105
|
+
result = `curl #{@config.host}/api/v4/groups/#{@group_id}/projects?private_token=#{@config.private_token}&id=#{@group_id}`
|
106
|
+
|
107
|
+
json = JSON result
|
108
|
+
|
109
|
+
get_project_id_temp json, 0
|
110
|
+
get_project_id_temp json, 1
|
111
|
+
|
112
|
+
puts "Project iOS id is: #{@hook_project_id_ios}, android id is #{@hook_project_id_android}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_project_id_temp(json, index)
|
116
|
+
temp_name = json[index]['name']
|
117
|
+
temp_id = json[index]['id']
|
118
|
+
if temp_name == @hook_project_android
|
119
|
+
@hook_project_id_android = temp_id
|
120
|
+
else
|
121
|
+
@hook_project_id_ios = temp_id
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def add_project_hook(id, url)
|
126
|
+
puts "ODM add hook url:#{url} to project #{id}".green
|
127
|
+
result = `curl #{@config.host}/api/v4/projects/#{id}/hooks?private_token=#{@config.private_token} -X POST -d "id=#{id}&url=#{url}&push_events=true"`
|
128
|
+
json = JSON result
|
129
|
+
puts json
|
130
|
+
end
|
131
|
+
|
132
|
+
def not_empty?(str)
|
133
|
+
if str.nil?
|
134
|
+
return false
|
135
|
+
else
|
136
|
+
if str.empty?
|
137
|
+
return false
|
138
|
+
end
|
139
|
+
return true
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|