nixenvironment 0.0.75 → 0.0.77

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4faafeedb013d7543ee6cd5121fd9981d581ae28
4
- data.tar.gz: b41f82b4a71e93f0edb3d3a679a2933e469198b9
3
+ metadata.gz: b86af60e19d716873c260f3e03b4054282c3d569
4
+ data.tar.gz: 4fbe4725f2639e52efb70269793c91e91f09d9de
5
5
  SHA512:
6
- metadata.gz: 6bc5167ced38fdeb15734d58672e74c6e4db597c18f4836eb8450749585048ab2f08f7e2cee5f666cb9a37849d7ad28c3aa4a935d8bd26c0f3461f419f618c24
7
- data.tar.gz: 7e6a402daa66516f6aab8635857a37554ab91a9736c840210acd02aa3b2500e5733f42a36957616f8afa9ef8825205fd59047c4892be890b6c59e23c39f5938d
6
+ metadata.gz: c57d21a9a174db9c60083c19b65bcb2be31292122cbdc4c79291f8ff481e18060cd5aae0ae8f566ec5cb1ef042adb9df7913d8835b29a159f62613d44fe7d9ca
7
+ data.tar.gz: 5fc56573955f6d973ddb8a0b0a3e5da013cce5dcd8c88373475c6dc8a445106b3a846799af53af6f93bd36454fa4a9a3bc9bf4b5bfe4f997a216bee6cbea3afa
data/bin/nixenvironment CHANGED
@@ -238,6 +238,56 @@ command :clean_working_copy do |c|
238
238
  c.action { |_args, options| clean_working_copy(options.all) }
239
239
  end
240
240
 
241
+ command :slave do |c|
242
+ c.syntax = 'nixenvironment slave'
243
+ c.description = 'Jenkins slave'
244
+ c.option '--init', 'Init Jenkins slave'
245
+ c.option '--start', 'Start Jenkins slave'
246
+ c.option '--deinit', 'Deinit Jenkins slave'
247
+ c.action do |_args, options|
248
+ if options.init
249
+ SlaveInitializer.new.start
250
+ elsif options.deinit
251
+ SlaveDeinitializer.new.start
252
+ end
253
+
254
+ if options.start
255
+ starter = SlaveStarter.new
256
+
257
+ begin
258
+ starter.start
259
+ rescue SystemExit, Interrupt
260
+ starter.stop
261
+ end
262
+ end
263
+ end
264
+ end
265
+
266
+ command :master do |c|
267
+ c.syntax = 'nixenvironment master'
268
+ c.description = 'Jenkins master'
269
+ c.option '--init', 'Init Jenkins master'
270
+ c.option '--start', 'Start Jenkins master'
271
+ c.option '--deinit', 'Deinit Jenkins master'
272
+ c.action do |_args, options|
273
+ if options.init
274
+ MasterInitializer.new.start
275
+ elsif options.deinit
276
+ MasterDeinitializer.new.start
277
+ end
278
+
279
+ if options.start
280
+ starter = MastertStarter.new
281
+
282
+ begin
283
+ starter.start
284
+ rescue SystemExit, Interrupt
285
+ starter.stop
286
+ end
287
+ end
288
+ end
289
+ end
290
+
241
291
  def init
242
292
  template_project_url = nil
243
293
  template_project_types = []
@@ -45,7 +45,7 @@ public static class NIXBuilder
45
45
 
46
46
  BuildTarget buildTarget;
47
47
 
48
- #if UNITY_4_6
48
+ #if UNITY_4_7
49
49
  buildTarget = BuildTarget.iPhone;
50
50
  #else
51
51
  buildTarget = BuildTarget.iOS;
@@ -89,7 +89,7 @@ public static class NIXBuilder
89
89
  {
90
90
  string projectPath = CommandLineReader.GetCustomArgument(BuildPathArgument);
91
91
  CreateFolder(projectPath);
92
- #if UNITY_4_6
92
+ #if UNITY_4_7
93
93
  BuildTarget buildTarget = BuildTarget.MetroPlayer;
94
94
  EditorUserBuildSettings.metroSDK = MetroSDK.PhoneSDK81;
95
95
  #else
@@ -7,3 +7,13 @@ require 'nixenvironment/build_env_vars_loader'
7
7
  require 'nixenvironment/plist'
8
8
  require 'nixenvironment/scm'
9
9
  require 'nixenvironment/deployer'
10
+
11
+ # Slave
12
+ require 'nixenvironment/jenkins/slave/slave_initializer'
13
+ require 'nixenvironment/jenkins/slave/slave_deinitializer'
14
+ require 'nixenvironment/jenkins/slave/slave_starter'
15
+
16
+ # Master
17
+ require 'nixenvironment/jenkins/master/master_initializer'
18
+ require 'nixenvironment/jenkins/master/master_deinitializer'
19
+ require 'nixenvironment/jenkins/master/master_starter'
@@ -0,0 +1,66 @@
1
+ require_relative 'paths'
2
+ require 'terminal-table'
3
+
4
+ module AppletHelper
5
+ include Paths
6
+
7
+ private
8
+ def path_to_jenkins_slave_applets
9
+ "#{path_to_environment}/Applets/Slave"
10
+ end
11
+
12
+ def path_to_jenkins_master_applet
13
+ "#{path_to_environment}/Applets/slave-agent (10.10).jnlp"
14
+ end
15
+
16
+ def applets_in_environment
17
+ Dir["#{path_to_jenkins_slave_applets}/*.jnlp"]
18
+ end
19
+
20
+ public
21
+ def should_start_slave
22
+ File.exist?(path_to_environment)
23
+ end
24
+
25
+ def start_master
26
+ `javaws "#{path_to_jenkins_master_applet}" 1>/dev/null`
27
+ end
28
+
29
+ def start_slave
30
+ applets = applets_in_environment
31
+
32
+ rows = []
33
+
34
+ applets.each_with_index do |applet_file, index|
35
+ file_name = File.basename(applet_file, ".jnlp")
36
+ rows << [index, file_name]
37
+ end
38
+
39
+ table = Terminal::Table.new :headings => ['Index', 'Slave name'], :rows => rows
40
+ puts(table)
41
+
42
+ while true
43
+ print('Enter index > ')
44
+ user_input = STDIN.gets.to_i
45
+
46
+ if (0...applets.count).include?(user_input)
47
+ `javaws "#{applets[user_input]}" 1>/dev/null`
48
+ break
49
+ end
50
+ end
51
+ end
52
+
53
+ def stop_applets
54
+ javaProcesses = `jps -v`
55
+ applets = applets_in_environment
56
+
57
+ applets.each do |file_path|
58
+ javaProcesses.each_line do |line|
59
+ if line.include? file_path
60
+ pid = line.split.first
61
+ Process.kill('QUIT', pid.to_i)
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'paths'
2
+
3
+ module BackupHelper
4
+ include Paths
5
+
6
+ def check_backup_exist
7
+ File.exist?(path_to_backup)
8
+ end
9
+
10
+ def remove_backup
11
+ FileUtils::rm_rf(path_to_backup)
12
+ end
13
+
14
+ def create_backup
15
+ FileUtils::mkdir_p(path_to_backup)
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'paths'
2
+
3
+ module GemHelper
4
+ def check_uninstalled_gems(gems)
5
+ for gem_name in gems
6
+ found = Gem::Specification.find_all_by_name(gem_name)
7
+
8
+ if found.count == 0
9
+ `sudo gem install #{gem_name}`
10
+ else
11
+ puts("#{gem_name} is already installed")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'paths'
2
+
3
+ module GitHelper
4
+ include Paths
5
+
6
+ private
7
+ def repos_changed
8
+ `git fetch origin 1>/dev/null`
9
+ `git diff origin/master` != ''
10
+ end
11
+
12
+ public
13
+ def clone_environment
14
+ FileUtils.mkdir_p(path_to_environment)
15
+
16
+ Dir.chdir(path_to_environment) { `git clone git@bitbucket.org:nixsolutions/ije.git .` }
17
+ end
18
+
19
+ def clone_provisioning_updater
20
+ FileUtils.mkdir_p(path_to_provisioning_updater)
21
+
22
+ Dir.chdir(path_to_provisioning_updater) { `git clone git@bitbucket.org:nixsolutions/npu.git .` }
23
+ end
24
+
25
+ def set_git_hook(&hook_block)
26
+ thread = Thread.new do
27
+ Dir.chdir(path_to_environment) do
28
+ while true
29
+ if repos_changed
30
+ `git pull`
31
+ hook_block.call()
32
+ end
33
+
34
+ sleep(15)
35
+ end
36
+ end
37
+ end
38
+
39
+ thread
40
+ end
41
+
42
+ def remove_local_environment
43
+ FileUtils.rm_rf(path_to_environment)
44
+ end
45
+
46
+ def remove_local_provisioning_updater
47
+ FileUtils.rm_rf(path_to_provisioning_updater)
48
+ end
49
+ end
@@ -0,0 +1,39 @@
1
+ require_relative 'paths'
2
+
3
+ module KeychainHelper
4
+ include Paths
5
+
6
+ private
7
+ def jenkins_keychain_name
8
+ 'XCodeKeys.keychain'
9
+ end
10
+
11
+ def path_to_jenkins_keychain
12
+ "#{path_to_environment}/Keychains/#{jenkins_keychain_name}"
13
+ end
14
+
15
+ def path_to_login_keychain
16
+ `security login | sed 's/^"\(.*\)"$/\1/'`
17
+ end
18
+
19
+ public
20
+ def add_jenkins_keychain
21
+ `security list -d user -s login.keychain #{path_to_jenkins_keychain}`
22
+ end
23
+
24
+ def set_default_jenkins_keychain
25
+ `security default -s #{path_to_jenkins_keychain}`
26
+ end
27
+
28
+ def unlock_jenkins_keychain
29
+ `security unlock -p 1 #{path_to_jenkins_keychain}`
30
+ end
31
+
32
+ def remove_jenkins_keychain
33
+ `security delete #{path_to_jenkins_keychain}` # Удаляет реальный кейчейн
34
+ end
35
+
36
+ def set_default_login_keychain
37
+ `security default -s #{path_to_login_keychain}`
38
+ end
39
+ end
@@ -0,0 +1,21 @@
1
+ module Paths
2
+ def root_jenkins_path
3
+ "#{Dir.home}/.ijenkins"
4
+ end
5
+
6
+ def path_to_unity_cache
7
+ "#{root_jenkins_path}/UnityCacheServer"
8
+ end
9
+
10
+ def path_to_environment
11
+ "#{root_jenkins_path}/environment"
12
+ end
13
+
14
+ def path_to_backup
15
+ "#{root_jenkins_path}/slave_backups"
16
+ end
17
+
18
+ def path_to_provisioning_updater
19
+ "#{root_jenkins_path}/Provisioning_updater"
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'paths'
2
+
3
+ module ProvisioningHelper
4
+ include Paths
5
+
6
+ private
7
+ def path_to_jenkins_provisioning_profiles
8
+ "#{path_to_environment}/Provisioning Profiles"
9
+ end
10
+
11
+ def path_to_provisioning_profiles
12
+ File.expand_path("#{Dir.home}/Library/MobileDevice/Provisioning Profiles")
13
+ end
14
+
15
+ def path_to_backup_provisioning_profiles
16
+ "#{path_to_backup}/Provisioning Profiles"
17
+ end
18
+
19
+ public
20
+ def move_provisioning_profiles_to_backup
21
+ FileUtils::mv(path_to_provisioning_profiles, path_to_backup_provisioning_profiles, :force => true)
22
+ end
23
+
24
+ def restore_backup_provisioning_profiles
25
+ FileUtils::mv(path_to_backup_provisioning_profiles, path_to_provisioning_profiles, :force => true)
26
+ end
27
+
28
+ def copy_jenkins_provisioning_profiles
29
+ FileUtils::cp_r("#{path_to_jenkins_provisioning_profiles}/.", path_to_provisioning_profiles)
30
+ end
31
+
32
+ def remove_local_provisioning_profiles
33
+ FileUtils::rm_r(path_to_provisioning_profiles)
34
+ end
35
+ end
@@ -0,0 +1,36 @@
1
+ require_relative 'paths'
2
+
3
+ module SshHelper
4
+ include Paths
5
+
6
+ private
7
+ def path_to_ssh
8
+ "#{Dir.home}/.ssh"
9
+ end
10
+
11
+ def path_to_jenkins_ssh
12
+ "#{path_to_environment}/ssh"
13
+ end
14
+
15
+ def path_to_backup_ssh
16
+ "#{path_to_backup}/ssh"
17
+ end
18
+
19
+ public
20
+ def move_ssh_to_backup
21
+ FileUtils::mv(path_to_ssh, path_to_backup_ssh, :force => true)
22
+ end
23
+
24
+ def restore_backup_ssh
25
+ FileUtils::mv(path_to_backup_ssh, path_to_ssh, :force => true)
26
+ end
27
+
28
+ def copy_jenkins_ssh
29
+ FileUtils::cp_r("#{path_to_jenkins_ssh}/.", path_to_ssh)
30
+ FileUtils::chmod(0700, "#{path_to_ssh}/id_rsa_ololo")
31
+ end
32
+
33
+ def remove_local_ssh
34
+ FileUtils::rm_r(path_to_ssh)
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../slave/slave_deinitializer'
2
+
3
+ class MasterDeinitializer < SlaveDeinitializer
4
+ def start
5
+ super
6
+
7
+ remove_local_provisioning_updater
8
+
9
+ FileUtils::rm_r(path_to_unity_cache)
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../slave/slave_initializer'
2
+
3
+ class MasterInitializer < SlaveInitializer
4
+ def start
5
+ super
6
+
7
+ clone_provisioning_updater
8
+ end
9
+ end
@@ -0,0 +1,48 @@
1
+ require_relative '../modules/applet_helper'
2
+ require_relative '../modules/paths'
3
+
4
+ class MastertStarter
5
+ include AppletHelper
6
+ include Paths
7
+
8
+ private
9
+ def kill_proc(name)
10
+ `pids=$(ps -fu $USER | grep "#{name}" | grep -v "grep" | awk '{print $2}')`
11
+ `for pid in ${pids[@]}; do kill -9 $pid; done`
12
+ end
13
+
14
+ public
15
+ def start
16
+ raise "Сan't run a slave." unless should_start_slave
17
+
18
+ # Applet
19
+ start_master
20
+
21
+ # Start Unity cache server
22
+ cacheThread = Thread.new do
23
+ FileUtils::mkdir_p("#{path_to_unity_cache}/Cache5.0")
24
+ FileUtils::mkdir_p("#{path_to_unity_cache}/Cache")
25
+ `#{path_to_environment}/CacheServer/RunOSX.command --path #{path_to_unity_cache}/Cache5.0 --legacypath #{path_to_unity_cache}/Cache`
26
+ end
27
+
28
+ # Start provisioning updater
29
+ serverThread = Thread.new do
30
+ Dir.chdir(path_to_provisioning_updater) do
31
+ `./run -e production -p 3000`
32
+ end
33
+ end
34
+
35
+ cacheThread.join
36
+ serverThread.join
37
+ true
38
+ end
39
+
40
+ def stop
41
+ stop_applets
42
+ `kill -9 "$(cat #{path_to_provisioning_updater}/tmp/pids/server.pid)" 2>/dev/null`
43
+ kill_proc("#{path_to_environment}/CacheServer/")
44
+ kill_proc("rails")
45
+
46
+ true
47
+ end
48
+ end
@@ -0,0 +1,35 @@
1
+ require_relative '../modules/ssh_helper'
2
+ require_relative '../modules/git_helper'
3
+ require_relative '../modules/provisioning_helper'
4
+ require_relative '../modules/keychain_helper'
5
+ require_relative '../modules/backup_helper'
6
+
7
+ class SlaveDeinitializer
8
+ include SshHelper
9
+ include GitHelper
10
+ include ProvisioningHelper
11
+ include KeychainHelper
12
+ include BackupHelper
13
+
14
+ def start
15
+ raise 'Backup is not exist' unless check_backup_exist
16
+
17
+ # Provisioning profiles
18
+ remove_local_provisioning_profiles
19
+ restore_backup_provisioning_profiles
20
+
21
+ # ssh
22
+ remove_local_ssh
23
+ restore_backup_ssh
24
+
25
+ # Keychain
26
+ remove_jenkins_keychain
27
+ set_default_login_keychain
28
+
29
+ # Backup
30
+ remove_backup
31
+ remove_local_environment
32
+
33
+ true
34
+ end
35
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../modules/ssh_helper'
2
+ require_relative '../modules/git_helper'
3
+ require_relative '../modules/provisioning_helper'
4
+ require_relative '../modules/keychain_helper'
5
+ require_relative '../modules/backup_helper'
6
+ require_relative '../modules/gem_helper'
7
+
8
+ class SlaveInitializer
9
+ include SshHelper
10
+ include GitHelper
11
+ include ProvisioningHelper
12
+ include KeychainHelper
13
+ include BackupHelper
14
+ include GemHelper
15
+
16
+ def start
17
+ raise 'Backup is already exist' if check_backup_exist
18
+
19
+ # Git
20
+ clone_environment
21
+
22
+ # Backup
23
+ create_backup
24
+
25
+ # .ssh
26
+ move_ssh_to_backup
27
+ copy_jenkins_ssh
28
+
29
+ # Keychain
30
+ add_jenkins_keychain
31
+ set_default_jenkins_keychain
32
+ unlock_jenkins_keychain
33
+
34
+ # Provisioning profiles
35
+ move_provisioning_profiles_to_backup
36
+ copy_jenkins_provisioning_profiles
37
+
38
+ # Gem
39
+ check_uninstalled_gems(['newman'])
40
+
41
+ true
42
+ end
43
+ end
@@ -0,0 +1,32 @@
1
+ require_relative '../modules/applet_helper'
2
+ require_relative '../modules/git_helper'
3
+ require_relative '../modules/provisioning_helper'
4
+
5
+ class SlaveStarter
6
+ include AppletHelper
7
+ include GitHelper
8
+ include ProvisioningHelper
9
+
10
+ def start
11
+ raise "Сan't run a slave." unless should_start_slave
12
+
13
+ # Git
14
+ hook_thread = set_git_hook do
15
+ remove_local_provisioning_profiles
16
+ copy_jenkins_provisioning_profiles
17
+ end
18
+
19
+ # Applet
20
+ start_slave
21
+
22
+ hook_thread.join
23
+
24
+ true
25
+ end
26
+
27
+ def stop
28
+ stop_applets
29
+
30
+ true
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Nixenvironment
2
- VERSION = '0.0.75'
2
+ VERSION = '0.0.77'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nixenvironment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.75
4
+ version: 0.0.77
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-20 00:00:00.000000000 Z
12
+ date: 2016-02-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cocoapods
@@ -240,6 +240,20 @@ files:
240
240
  - lib/nixenvironment/config.rb
241
241
  - lib/nixenvironment/deployer.rb
242
242
  - lib/nixenvironment/git.rb
243
+ - lib/nixenvironment/jenkins/Modules/applet_helper.rb
244
+ - lib/nixenvironment/jenkins/Modules/backup_helper.rb
245
+ - lib/nixenvironment/jenkins/Modules/gem_helper.rb
246
+ - lib/nixenvironment/jenkins/Modules/git_helper.rb
247
+ - lib/nixenvironment/jenkins/Modules/keychain_helper.rb
248
+ - lib/nixenvironment/jenkins/Modules/paths.rb
249
+ - lib/nixenvironment/jenkins/Modules/provisioning_helper.rb
250
+ - lib/nixenvironment/jenkins/Modules/ssh_helper.rb
251
+ - lib/nixenvironment/jenkins/master/master_deinitializer.rb
252
+ - lib/nixenvironment/jenkins/master/master_initializer.rb
253
+ - lib/nixenvironment/jenkins/master/master_starter.rb
254
+ - lib/nixenvironment/jenkins/slave/slave_deinitializer.rb
255
+ - lib/nixenvironment/jenkins/slave/slave_initializer.rb
256
+ - lib/nixenvironment/jenkins/slave/slave_starter.rb
243
257
  - lib/nixenvironment/plist.rb
244
258
  - lib/nixenvironment/scm.rb
245
259
  - lib/nixenvironment/version.rb
@@ -272,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
286
  version: '0'
273
287
  requirements: []
274
288
  rubyforge_project:
275
- rubygems_version: 2.4.8
289
+ rubygems_version: 2.0.14
276
290
  signing_key:
277
291
  specification_version: 4
278
292
  summary: NIX projects build and deploy utility