dtk-shell 0.10.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.
Files changed (191) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/Gemfile_dev +13 -0
  4. data/README.md +121 -0
  5. data/bin/dtk-execute +32 -0
  6. data/bin/dtk-run +92 -0
  7. data/bin/dtk-shell +31 -0
  8. data/dtk-shell.gemspec +50 -0
  9. data/lib/auxiliary.rb +61 -0
  10. data/lib/bundler_monkey_patch.rb +26 -0
  11. data/lib/client.rb +58 -0
  12. data/lib/command_helper.rb +33 -0
  13. data/lib/command_helpers/git_repo.rb +589 -0
  14. data/lib/command_helpers/git_repo/merge.rb +153 -0
  15. data/lib/command_helpers/jenkins_client.rb +106 -0
  16. data/lib/command_helpers/jenkins_client/config_xml.rb +288 -0
  17. data/lib/command_helpers/service_importer.rb +251 -0
  18. data/lib/command_helpers/service_link.rb +33 -0
  19. data/lib/command_helpers/test_module_creator.rb +69 -0
  20. data/lib/command_helpers/test_module_templates/dtk.model.yaml.eruby +10 -0
  21. data/lib/command_helpers/test_module_templates/spec_helper.rb.eruby +10 -0
  22. data/lib/command_helpers/test_module_templates/temp_component_spec.rb.eruby +5 -0
  23. data/lib/commands.rb +57 -0
  24. data/lib/commands/common/thor/access_control.rb +133 -0
  25. data/lib/commands/common/thor/action_result_handler.rb +74 -0
  26. data/lib/commands/common/thor/assembly_template.rb +92 -0
  27. data/lib/commands/common/thor/assembly_workspace.rb +1801 -0
  28. data/lib/commands/common/thor/base_command_helper.rb +59 -0
  29. data/lib/commands/common/thor/clone.rb +82 -0
  30. data/lib/commands/common/thor/common.rb +88 -0
  31. data/lib/commands/common/thor/common_base.rb +49 -0
  32. data/lib/commands/common/thor/create_target.rb +70 -0
  33. data/lib/commands/common/thor/edit.rb +255 -0
  34. data/lib/commands/common/thor/inventory_parser.rb +98 -0
  35. data/lib/commands/common/thor/list_diffs.rb +128 -0
  36. data/lib/commands/common/thor/module.rb +1011 -0
  37. data/lib/commands/common/thor/module/import.rb +210 -0
  38. data/lib/commands/common/thor/node.rb +53 -0
  39. data/lib/commands/common/thor/poller.rb +65 -0
  40. data/lib/commands/common/thor/pull_clone_changes.rb +28 -0
  41. data/lib/commands/common/thor/pull_from_remote.rb +152 -0
  42. data/lib/commands/common/thor/puppet_forge.rb +72 -0
  43. data/lib/commands/common/thor/purge_clone.rb +101 -0
  44. data/lib/commands/common/thor/push_clone_changes.rb +162 -0
  45. data/lib/commands/common/thor/push_to_remote.rb +94 -0
  46. data/lib/commands/common/thor/remotes.rb +71 -0
  47. data/lib/commands/common/thor/reparse.rb +40 -0
  48. data/lib/commands/common/thor/set_required_attributes.rb +46 -0
  49. data/lib/commands/thor/account.rb +239 -0
  50. data/lib/commands/thor/assembly.rb +356 -0
  51. data/lib/commands/thor/attribute.rb +79 -0
  52. data/lib/commands/thor/component.rb +70 -0
  53. data/lib/commands/thor/component_module.rb +501 -0
  54. data/lib/commands/thor/component_template.rb +174 -0
  55. data/lib/commands/thor/dependency.rb +34 -0
  56. data/lib/commands/thor/developer.rb +144 -0
  57. data/lib/commands/thor/dtk.rb +152 -0
  58. data/lib/commands/thor/library.rb +125 -0
  59. data/lib/commands/thor/node.rb +504 -0
  60. data/lib/commands/thor/node_template.rb +94 -0
  61. data/lib/commands/thor/project.rb +34 -0
  62. data/lib/commands/thor/provider.rb +233 -0
  63. data/lib/commands/thor/remotes.rb +49 -0
  64. data/lib/commands/thor/service.rb +941 -0
  65. data/lib/commands/thor/service_module.rb +914 -0
  66. data/lib/commands/thor/state_change.rb +25 -0
  67. data/lib/commands/thor/target.rb +250 -0
  68. data/lib/commands/thor/task.rb +116 -0
  69. data/lib/commands/thor/test_module.rb +310 -0
  70. data/lib/commands/thor/utils.rb +21 -0
  71. data/lib/commands/thor/workspace.rb +685 -0
  72. data/lib/config/cacert.pem +3785 -0
  73. data/lib/config/client.conf.header +20 -0
  74. data/lib/config/configuration.rb +99 -0
  75. data/lib/config/default.conf +16 -0
  76. data/lib/config/disk_cacher.rb +80 -0
  77. data/lib/configurator.rb +176 -0
  78. data/lib/context_router.rb +44 -0
  79. data/lib/core.rb +497 -0
  80. data/lib/domain/git_adapter.rb +412 -0
  81. data/lib/domain/git_error_handler.rb +64 -0
  82. data/lib/domain/response.rb +285 -0
  83. data/lib/domain/response/error_handler.rb +86 -0
  84. data/lib/dtk-shell/version.rb +20 -0
  85. data/lib/dtk_constants.rb +40 -0
  86. data/lib/dtk_error.rb +114 -0
  87. data/lib/dtk_logger.rb +126 -0
  88. data/lib/dtk_shell.rb +31 -0
  89. data/lib/error.rb +85 -0
  90. data/lib/execute.rb +29 -0
  91. data/lib/execute/cli_pure/cli_rerouter.rb +102 -0
  92. data/lib/execute/command.rb +40 -0
  93. data/lib/execute/command/api_call.rb +60 -0
  94. data/lib/execute/command/api_call/map.rb +60 -0
  95. data/lib/execute/command/api_call/service.rb +91 -0
  96. data/lib/execute/command/api_call/translation_term.rb +119 -0
  97. data/lib/execute/command/rest_call.rb +37 -0
  98. data/lib/execute/command_processor.rb +30 -0
  99. data/lib/execute/command_processor/rest_call.rb +59 -0
  100. data/lib/execute/error_usage.rb +21 -0
  101. data/lib/execute/execute_context.rb +86 -0
  102. data/lib/execute/execute_context/result_store.rb +37 -0
  103. data/lib/execute/script.rb +64 -0
  104. data/lib/execute/script/add_tenant.rb +121 -0
  105. data/lib/git-logs/git.log +0 -0
  106. data/lib/parser/adapters/option_parser.rb +70 -0
  107. data/lib/parser/adapters/thor.rb +555 -0
  108. data/lib/parser/adapters/thor/common_option_defs.rb +40 -0
  109. data/lib/require_first.rb +104 -0
  110. data/lib/search_hash.rb +44 -0
  111. data/lib/shell.rb +261 -0
  112. data/lib/shell/context.rb +1065 -0
  113. data/lib/shell/context_aux.rb +46 -0
  114. data/lib/shell/domain/active_context.rb +186 -0
  115. data/lib/shell/domain/context_entity.rb +89 -0
  116. data/lib/shell/domain/context_params.rb +223 -0
  117. data/lib/shell/domain/override_tasks.rb +88 -0
  118. data/lib/shell/domain/shadow_entity.rb +76 -0
  119. data/lib/shell/header_shell.rb +44 -0
  120. data/lib/shell/help_monkey_patch.rb +283 -0
  121. data/lib/shell/interactive_wizard.rb +225 -0
  122. data/lib/shell/message_queue.rb +63 -0
  123. data/lib/shell/parse_monkey_patch.rb +39 -0
  124. data/lib/shell/status_monitor.rb +124 -0
  125. data/lib/task_status.rb +83 -0
  126. data/lib/task_status/refresh_mode.rb +77 -0
  127. data/lib/task_status/snapshot_mode.rb +28 -0
  128. data/lib/task_status/stream_mode.rb +48 -0
  129. data/lib/task_status/stream_mode/element.rb +101 -0
  130. data/lib/task_status/stream_mode/element/format.rb +101 -0
  131. data/lib/task_status/stream_mode/element/hierarchical_task.rb +100 -0
  132. data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +72 -0
  133. data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +93 -0
  134. data/lib/task_status/stream_mode/element/hierarchical_task/result/components.rb +26 -0
  135. data/lib/task_status/stream_mode/element/hierarchical_task/result/node_level.rb +26 -0
  136. data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +34 -0
  137. data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +53 -0
  138. data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +53 -0
  139. data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +42 -0
  140. data/lib/task_status/stream_mode/element/no_results.rb +26 -0
  141. data/lib/task_status/stream_mode/element/render.rb +59 -0
  142. data/lib/task_status/stream_mode/element/stage.rb +84 -0
  143. data/lib/task_status/stream_mode/element/stage/render.rb +76 -0
  144. data/lib/task_status/stream_mode/element/task_end.rb +35 -0
  145. data/lib/task_status/stream_mode/element/task_start.rb +37 -0
  146. data/lib/util/common_util.rb +37 -0
  147. data/lib/util/console.rb +235 -0
  148. data/lib/util/dtk_puppet.rb +65 -0
  149. data/lib/util/module_util.rb +66 -0
  150. data/lib/util/os_util.rb +385 -0
  151. data/lib/util/permission_util.rb +31 -0
  152. data/lib/util/remote_dependency_util.rb +84 -0
  153. data/lib/util/ssh_util.rb +94 -0
  154. data/lib/view_processor.rb +129 -0
  155. data/lib/view_processor/augmented_simple_list.rb +44 -0
  156. data/lib/view_processor/hash_pretty_print.rb +123 -0
  157. data/lib/view_processor/simple_list.rb +156 -0
  158. data/lib/view_processor/table_print.rb +309 -0
  159. data/lib/violation.rb +86 -0
  160. data/lib/violation/attribute.rb +76 -0
  161. data/lib/violation/fix.rb +26 -0
  162. data/lib/violation/fix/result.rb +73 -0
  163. data/lib/violation/fix/result/error.rb +34 -0
  164. data/lib/violation/fix/set_attribute.rb +41 -0
  165. data/lib/violation/sub_classes.rb +60 -0
  166. data/puppet/manifests/init.pp +72 -0
  167. data/puppet/manifests/params.pp +16 -0
  168. data/puppet/r8meta.puppet.yml +35 -0
  169. data/puppet/templates/bash_profile.erb +2 -0
  170. data/puppet/templates/client.conf.erb +1 -0
  171. data/puppet/templates/dtkclient.erb +2 -0
  172. data/spec/component_module_spec.rb +34 -0
  173. data/spec/dependency_spec.rb +6 -0
  174. data/spec/dtk_shell_spec.rb +13 -0
  175. data/spec/dtk_spec.rb +33 -0
  176. data/spec/lib/spec_helper.rb +10 -0
  177. data/spec/lib/spec_thor.rb +108 -0
  178. data/spec/node_template_spec.rb +24 -0
  179. data/spec/project_spec.rb +6 -0
  180. data/spec/repo_spec.rb +7 -0
  181. data/spec/response_spec.rb +52 -0
  182. data/spec/service_module_spec.rb +38 -0
  183. data/spec/service_spec.rb +50 -0
  184. data/spec/state_change_spec.rb +7 -0
  185. data/spec/table_print_spec.rb +48 -0
  186. data/spec/target_spec.rb +57 -0
  187. data/spec/task_spec.rb +28 -0
  188. data/views/assembly/augmented_simple_list.rb +12 -0
  189. data/views/assembly_template/augmented_simple_list.rb +12 -0
  190. data/views/list_task/augmented_simple_list.rb +12 -0
  191. metadata +421 -0
@@ -0,0 +1,153 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module DTK; module Client; class CommandHelper
19
+ class GitRepo
20
+ class Merge
21
+
22
+ def initialize(repo, remote_branch_ref, opts = {})
23
+ @repo = repo
24
+ @remote_branch_ref = remote_branch_ref
25
+ @local_branch = repo.local_branch_name
26
+
27
+ # options
28
+ @opts_commit_sha = opts[:commit_sha]
29
+ @opts_force = opts[:force]
30
+ @opts_ignore_dependency_merge_conflict = opts[:ignore_dependency_merge_conflict]
31
+ @opts_full_module_name = opts[:full_module_name]
32
+ @opts_command = opts[:command]
33
+ end
34
+
35
+ def self.merge(repo, remote_branch_ref, opts = {})
36
+ new(repo, remote_branch_ref, opts).merge
37
+ end
38
+
39
+ def merge
40
+ if @opts_force
41
+ merge_force()
42
+ else
43
+ # check if merge needed
44
+ merge_rel = merge_relationship()
45
+ case merge_rel
46
+ when :equal
47
+ response__no_diffs()
48
+ when :local_ahead, :branchpoint
49
+ merge_not_fast_forward(merge_rel)
50
+ when :local_behind
51
+ merge_simple()
52
+ else
53
+ raise Error.new("Unexpected merge_rel (#{merge_rel})")
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def merge_force
61
+ diffs = compute_diffs()
62
+ # TODO: should put in a commit message that merged from remote repo
63
+ @repo.merge_theirs(@remote_branch_ref)
64
+ response(diffs)
65
+ end
66
+
67
+ def merge_not_fast_forward(merge_rel)
68
+ if any_conflicts?
69
+ # @opts_ignore_dependency_merge_conflict means called indirectly
70
+ if @opts_ignore_dependency_merge_conflict
71
+ # TODO: hard-wired that dependency is a component module in message: 'component-module/..
72
+ custom_message = "Unable to do fast-forward merge. You can go to 'component-module/#{@opts_full_module_name}' and pull with --force option but all local changes will be lost."
73
+ response(compute_diffs, :custom_message => custom_message)
74
+ else
75
+ err_msg = 'Unable to do fast-forward merge. You can use --force'
76
+ err_msg << " on #{@opts_command}" if @opts_command
77
+ err_msg << ', but all local changes will be lost on target that is being pushed to.'
78
+ raise ErrorUsage.new(err_msg)
79
+ end
80
+ elsif merge_rel == :local_ahead
81
+ response__no_diffs(:custom_message => 'No op because local module is ahead')
82
+ else
83
+ merge_simple()
84
+ end
85
+ end
86
+
87
+ def merge_simple
88
+ # see if any diffs between fetched remote and local branch
89
+ # this has be done after commit
90
+ diffs = compute_diffs()
91
+ return diffs unless diffs.any_diffs?()
92
+
93
+ safe_execute do
94
+ # TODO: should put in a commit message that merged from remote repo
95
+ @repo.merge(@remote_branch_ref)
96
+ end
97
+
98
+ if commit_sha = @opts_commit_sha
99
+ if commit_sha != @repo.head_commit_sha()
100
+ raise Error.new("Git synchronization problem: expected local head to have sha (#{commit_sha})")
101
+ end
102
+ end
103
+
104
+ response(diffs)
105
+ end
106
+
107
+ def merge_relationship
108
+ @repo.merge_relationship(:remote_branch, @remote_branch_ref)
109
+ end
110
+
111
+ def any_conflicts?
112
+ # TODO: optimization is to combine this with mereg to have merge_if_no_conflics?
113
+ # and if no conflicts just commit and merge --no-commit
114
+ ret = nil
115
+ begin
116
+ @repo.command('merge',['--no-commit', @remote_branch_ref])
117
+ rescue ::Git::GitExecuteError
118
+ ret = true
119
+ ensure
120
+ safe_execute do
121
+ @repo.command('merge',['--abort'])
122
+ end
123
+ end
124
+ ret
125
+ end
126
+
127
+ def response__no_diffs(opts_response = {})
128
+ response(diffs__no_diffs(), opts_response)
129
+ end
130
+
131
+ def response(diffs, opts_response = {})
132
+ { :diffs => diffs, :commit_sha => @repo.head_commit_sha() }.merge(opts_response)
133
+ end
134
+
135
+ def diffs__no_diffs
136
+ GitRepo.diffs__no_diffs
137
+ end
138
+
139
+ def compute_diffs
140
+ GitRepo.compute_diffs(@repo, @remote_branch_ref)
141
+ end
142
+
143
+ def safe_execute(&block)
144
+ begin
145
+ yield
146
+ rescue Exception
147
+ nil
148
+ end
149
+ end
150
+
151
+ end
152
+ end
153
+ end; end; end
@@ -0,0 +1,106 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ # TODO: Marked for removal [Haris] - Do we need this?
19
+ require 'jenkins-client'
20
+ module DTK; module Client
21
+ class JenkinsClient
22
+ require File.expand_path('jenkins_client/config_xml', File.dirname(__FILE__))
23
+
24
+ def self.create_service_module_project(module_id,module_name,repo_url,branch)
25
+ jenkins_project_name = module_name
26
+ config_xml_contents = ConfigXML.generate_service_module_project(repo_url,module_id,branch)
27
+ connection().create_job(jenkins_project_name,config_xml_contents)
28
+ end
29
+
30
+ def self.create_service_module_project?(module_id,module_name,repo_url,branch)
31
+ jenkins_project_name = module_name
32
+ jobs = get_jobs()||[]
33
+ #no op if job exists already
34
+ unless jobs.find{|j|j["name"] == jenkins_project_name}
35
+ create_service_module_project(module_id,module_name,repo_url,branch)
36
+ end
37
+ end
38
+
39
+ def self.create_assembly_project(assembly_name,assembly_id)
40
+ jenkins_project_name = assembly_name.gsub(/::/,"-")
41
+ config_xml_contents = ConfigXML.generate_assembly_project(assembly_id)
42
+ connection().create_job(jenkins_project_name,config_xml_contents)
43
+ end
44
+
45
+ def self.create_assembly_project?(assembly_name,assembly_id)
46
+ jenkins_project_name = assembly_name.gsub(/::/,"-")
47
+ jobs = get_jobs()||[]
48
+ #no op if job exists already
49
+ unless jobs.find{|j|j["name"] == jenkins_project_name}
50
+ create_assembly_project(assembly_name,assembly_id)
51
+ end
52
+ end
53
+
54
+ def self.get_jobs()
55
+ connection().get_jobs()
56
+ end
57
+
58
+ private
59
+ def self.connection()
60
+ return @connection if @connection
61
+ #TODO: hardwired
62
+ connection_hash = {
63
+ :username => "rich",
64
+ :password => "test",
65
+ :url => "http://ec2-107-22-254-226.compute-1.amazonaws.com:8080"
66
+ }
67
+ @connection = Connection.new(connection_hash)
68
+ end
69
+
70
+ class Connection < Hash
71
+ def initialize(connection_hash)
72
+ super()
73
+ merge!(connection_hash)
74
+ set_connection()
75
+ end
76
+ def create_job(job_name,config_xml_contents)
77
+ ::Jenkins::Client::Job.create(job_name, config_xml_contents)
78
+ end
79
+
80
+ def get_info()
81
+ get('api/json')
82
+ end
83
+
84
+ def get_jobs()
85
+ get_info()["jobs"]
86
+ end
87
+ private
88
+ #TODO: one issue with the jenkins-client adapter is that it a singleton and thus only allows connection under one user to one jenkins server
89
+ def set_connection()
90
+ ::Jenkins::Client.configure do |c|
91
+ c.username = self[:username]
92
+ c.password = self[:password]
93
+ c.url = self[:url]
94
+ end
95
+ end
96
+
97
+ def get(path)
98
+ faraday_response = ::Jenkins::Client.get(path)
99
+ unless [200].include?(faraday_response.status)
100
+ raise Error.new("Bad response from Jenkins (status = #{faraday_response.status.to_s})")
101
+ end
102
+ faraday_response.body
103
+ end
104
+ end
105
+ end
106
+ end; end
@@ -0,0 +1,288 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ #TODO: should haev separet file sfor each template
19
+ require 'erubis'
20
+ class DTK::Client::JenkinsClient
21
+ module ConfigXML
22
+ #TODO: this is not working now
23
+ def self.generate_service_module_project(repo_url,module_id,branch)
24
+ #TODO: not using branch argument
25
+ #TODO: did not put in module_id yet
26
+ template_bindings = {
27
+ :repo_url => repo_url
28
+ }
29
+ ConfigXMLTemplateServiceModule.result(template_bindings)
30
+ end
31
+ def self.generate_assembly_project(assembly_id)
32
+ #TODO: not using branch argument
33
+ #TODO: did not put in module_id yet
34
+ template_bindings = {
35
+ :assembly_id => assembly_id
36
+ }
37
+ ConfigXMLTemplateAssembly.result(template_bindings)
38
+ end
39
+
40
+ ConfigXMLTemplateServiceModule = Erubis::Eruby.new <<eos
41
+ <?xml version='1.0' encoding='UTF-8'?>
42
+ <project>
43
+ <actions/>
44
+ <description></description>
45
+ <keepDependencies>false</keepDependencies>
46
+ <properties>
47
+ <com.gmail.ikeike443.PlayAutoTestJobProperty/>
48
+ </properties>
49
+ <scm class="hudson.plugins.git.GitSCM">
50
+ <configVersion>2</configVersion>
51
+ <userRemoteConfigs>
52
+ <hudson.plugins.git.UserRemoteConfig>
53
+ <name></name>
54
+ <refspec></refspec>
55
+ <url><%= repo_url %></url>
56
+ </hudson.plugins.git.UserRemoteConfig>
57
+ </userRemoteConfigs>
58
+ <branches>
59
+ <hudson.plugins.git.BranchSpec>
60
+ <name>**</name>
61
+ </hudson.plugins.git.BranchSpec>
62
+ </branches>
63
+ <disableSubmodules>false</disableSubmodules>
64
+ <recursiveSubmodules>false</recursiveSubmodules>
65
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
66
+ <authorOrCommitter>false</authorOrCommitter>
67
+ <clean>false</clean>
68
+ <wipeOutWorkspace>false</wipeOutWorkspace>
69
+ <pruneBranches>false</pruneBranches>
70
+ <remotePoll>false</remotePoll>
71
+ <ignoreNotifyCommit>false</ignoreNotifyCommit>
72
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
73
+ <gitTool>Default</gitTool>
74
+ <submoduleCfg class="list"/>
75
+ <relativeTargetDir></relativeTargetDir>
76
+ <reference></reference>
77
+ <excludedRegions></excludedRegions>
78
+ <excludedUsers></excludedUsers>
79
+ <gitConfigName></gitConfigName>
80
+ <gitConfigEmail></gitConfigEmail>
81
+ <skipTag>false</skipTag>
82
+ <includedRegions></includedRegions>
83
+ <scmName></scmName>
84
+ </scm>
85
+ <canRoam>true</canRoam>
86
+ <disabled>false</disabled>
87
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
88
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
89
+ <triggers class="vector"/>
90
+ <concurrentBuild>false</concurrentBuild>
91
+ <builders>
92
+ <hudson.tasks.Shell>
93
+ <command>ruby /var/lib/jenkins/r8_e2e.rb</command>
94
+ </hudson.tasks.Shell>
95
+ </builders>
96
+ <publishers>
97
+ <hudson.plugins.emailext.ExtendedEmailPublisher>
98
+ <recipientList>$DEFAULT_RECIPIENTS</recipientList>
99
+ <configuredTriggers>
100
+ <hudson.plugins.emailext.plugins.trigger.FailureTrigger>
101
+ <email>
102
+ <recipientList></recipientList>
103
+ <subject>$PROJECT_DEFAULT_SUBJECT</subject>
104
+ <body>$PROJECT_DEFAULT_CONTENT</body>
105
+ <sendToDevelopers>true</sendToDevelopers>
106
+ <sendToRequester>false</sendToRequester>
107
+ <includeCulprits>false</includeCulprits>
108
+ <sendToRecipientList>true</sendToRecipientList>
109
+ </email>
110
+ </hudson.plugins.emailext.plugins.trigger.FailureTrigger>
111
+ <hudson.plugins.emailext.plugins.trigger.StillFailingTrigger>
112
+ <email>
113
+ <recipientList></recipientList>
114
+ <subject>$PROJECT_DEFAULT_SUBJECT</subject>
115
+ <body>$PROJECT_DEFAULT_CONTENT</body>
116
+ <sendToDevelopers>true</sendToDevelopers>
117
+ <sendToRequester>false</sendToRequester>
118
+ <includeCulprits>false</includeCulprits>
119
+ <sendToRecipientList>false</sendToRecipientList>
120
+ </email>
121
+ </hudson.plugins.emailext.plugins.trigger.StillFailingTrigger>
122
+ <hudson.plugins.emailext.plugins.trigger.FixedTrigger>
123
+ <email>
124
+ <recipientList></recipientList>
125
+ <subject>$PROJECT_DEFAULT_SUBJECT</subject>
126
+ <body>$PROJECT_DEFAULT_CONTENT</body>
127
+ <sendToDevelopers>true</sendToDevelopers>
128
+ <sendToRequester>false</sendToRequester>
129
+ <includeCulprits>false</includeCulprits>
130
+ <sendToRecipientList>true</sendToRecipientList>
131
+ </email>
132
+ </hudson.plugins.emailext.plugins.trigger.FixedTrigger>
133
+ </configuredTriggers>
134
+ <contentType>default</contentType>
135
+ <defaultSubject>$DEFAULT_SUBJECT</defaultSubject>
136
+ <defaultContent>${JELLY_SCRIPT,template=&quot;html&quot;}</defaultContent>
137
+ <attachmentsPattern></attachmentsPattern>
138
+ </hudson.plugins.emailext.ExtendedEmailPublisher>
139
+ </publishers>
140
+ <buildWrappers/>
141
+ </project>
142
+ eos
143
+
144
+
145
+ ConfigXMLTemplateAssembly = Erubis::Eruby.new <<eos
146
+ <?xml version='1.0' encoding='UTF-8'?>
147
+ <project>
148
+ <actions/>
149
+ <description></description>
150
+ <keepDependencies>false</keepDependencies>
151
+ <properties>
152
+ <com.gmail.ikeike443.PlayAutoTestJobProperty/>
153
+ </properties>
154
+ <scm class="hudson.scm.NullSCM"/>
155
+ <canRoam>true</canRoam>
156
+ <disabled>false</disabled>
157
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
158
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
159
+ <triggers class="vector"/>
160
+ <concurrentBuild>false</concurrentBuild>
161
+ <builders>
162
+ <hudson.tasks.Shell>
163
+ <command>#!/usr/bin/env ruby
164
+
165
+ require &apos;rubygems&apos;
166
+ require &apos;rest_client&apos;
167
+ require &apos;pp&apos;
168
+ require &apos;json&apos;
169
+
170
+ STDOUT.sync = true
171
+
172
+ ENDPOINT = &apos;http://ec2-54-247-191-95.eu-west-1.compute.amazonaws.com:7000&apos;
173
+ ASSEMBLY_ID = &apos;<%= assembly_id %>&apos;
174
+
175
+ # controling &apos;pretty-print&apos; in log file
176
+ JSON_OUTPUT_ENABLED = false
177
+
178
+ # Method for deleting assembly instances
179
+ def deleteAssembly(assemblyId)
180
+ responseAssemblyDelete = RestClient.post(ENDPOINT + &apos;/rest/assembly/delete&apos;, &apos;assembly_id&apos; =&gt; assemblyId)
181
+ puts &quot;Assembly has been deleted! Response: #{responseAssemblyDelete}&quot;
182
+ end
183
+
184
+ #
185
+ # Method for pretty print of json responses
186
+ def json_print(json)
187
+ pp json if JSON_OUTPUT_ENABLED
188
+ end
189
+
190
+ pp &quot;Script has been started!&quot;
191
+
192
+ puts &quot;Using template ID: #{ASSEMBLY_ID}&quot;
193
+
194
+ # Stage the assembly
195
+ stageAssembly = RestClient.post(ENDPOINT + &apos;/rest/assembly/stage&apos;, &apos;assembly_id&apos; =&gt; ASSEMBLY_ID)
196
+ assemblyId = JSON.parse(stageAssembly)[&quot;data&quot;][&quot;assembly_id&quot;]
197
+
198
+ puts &quot;Using stage assembly ID: #{assemblyId}&quot;
199
+
200
+ # Create a task for the cloned assembly instance
201
+ responseTask = RestClient.post(ENDPOINT + &apos;/rest/assembly/create_task&apos;, &apos;assembly_id&apos; =&gt; assemblyId)
202
+ # Extract task id
203
+ taskId = JSON.parse(responseTask)[&quot;data&quot;][&quot;task_id&quot;]
204
+ # Execute the task
205
+ puts &quot;Starting task id: #{taskId}&quot;
206
+ responseTaskExecute = RestClient.post(ENDPOINT + &apos;/rest/task/execute&apos;, &apos;task_id&apos; =&gt; taskId)
207
+
208
+ taskStatus = &apos;executing&apos;
209
+
210
+ while taskStatus.include? &apos;executing&apos;
211
+ sleep 20
212
+ responseTaskStatus = RestClient.post(ENDPOINT + &apos;/rest/task/status&apos;, &apos;task_id &apos;=&gt; taskId)
213
+ taskFullResponse = JSON.parse(responseTaskStatus)
214
+ taskStatus = taskFullResponse[&quot;data&quot;][&quot;status&quot;]
215
+ puts &quot;Task status: #{taskStatus}&quot;
216
+ json_print JSON.parse(responseTaskStatus)
217
+ end
218
+
219
+ if taskStatus.include? &apos;fail&apos;
220
+ # Print error response from the service
221
+ puts &quot;Smoke test failed, response: &quot;
222
+ pp taskFullResponse
223
+ # Delete the cloned assembly&apos;s instance
224
+ deleteAssembly(assemblyId)
225
+ abort(&quot;Task with ID #{taskId} failed!&quot;)
226
+ else
227
+ puts &quot;Task with ID #{taskId} success!&quot;
228
+ end
229
+
230
+
231
+ #Create a task for the smoke test
232
+ responseSmokeTest = RestClient.post(ENDPOINT + &apos;/rest/assembly/create_smoketests_task&apos;, &apos;assembly_id&apos; =&gt; assemblyId)
233
+ json_print responseSmokeTest
234
+
235
+ #Extract task id
236
+ smokeTestId = JSON.parse(responseSmokeTest)[&quot;data&quot;][&quot;task_id&quot;]
237
+ puts &quot;Created smoke test task with ID: #{smokeTestId}&quot;
238
+ #Execute the task
239
+ responseSmokeExecute = RestClient.post(ENDPOINT + &apos;/rest/task/execute&apos;, &apos;task_id&apos; =&gt; smokeTestId)
240
+
241
+ json_print JSON.parse(responseSmokeExecute)
242
+
243
+ puts &quot;Starting smoke test task with ID: #{smokeTestId}&quot;
244
+
245
+ smokeStatus = &apos;executing&apos;
246
+
247
+ while smokeStatus.include? &apos;executing&apos;
248
+ sleep 20
249
+ responseSmokeStatus = RestClient.post(ENDPOINT + &apos;/rest/task/status&apos;, &apos;task_id &apos;=&gt; smokeTestId)
250
+ fullResponse = JSON.parse(responseSmokeStatus)
251
+ smokeStatus = fullResponse[&quot;data&quot;][&quot;status&quot;]
252
+ puts &quot;Smoke test status: #{smokeStatus}&quot;
253
+ end
254
+
255
+ if smokeStatus.include? &apos;failed&apos;
256
+ # Delete the cloned assembly&apos;s instance
257
+ puts &quot;Smoke test failed, response: &quot;
258
+ pp fullResponse
259
+
260
+ # Getting log files for failed jobs
261
+ task_log_response = RestClient.post(ENDPOINT + &apos;/rest/task/get_logs&apos;, &apos;task_id &apos;=&gt; smokeTestId)
262
+ puts &quot;Logs response:&quot;
263
+ pp JSON.parse(task_log_response)
264
+
265
+ deleteAssembly(assemblyId)
266
+ abort(&quot;Smoke test failed.&quot;)
267
+ end
268
+
269
+ # Delete the cloned assembly&apos;s instance, this is the must!
270
+ #deleteAssembly(assemblyId)
271
+
272
+ #abort(&quot;Testing failure mail report.&quot;)
273
+ </command>
274
+ </hudson.tasks.Shell>
275
+ </builders>
276
+ <publishers>
277
+ <hudson.tasks.Mailer>
278
+ <recipients>r8-jenkins@atlantbh.com</recipients>
279
+ <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
280
+ <sendToIndividuals>false</sendToIndividuals>
281
+ </hudson.tasks.Mailer>
282
+ </publishers>
283
+ <buildWrappers/>
284
+ </project>
285
+ eos
286
+
287
+ end
288
+ end