Class: Vx::Builder::Script::Prepare
- Inherits:
-
Struct
- Object
- Struct
- Vx::Builder::Script::Prepare
- Includes:
- Common::Helper::UploadShCommand, Helper::TraceShCommand
- Defined in:
- lib/vx/builder/script/prepare.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Instance Method Summary collapse
Methods included from Helper::TraceShCommand
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app
7 8 9 |
# File 'lib/vx/builder/script/prepare.rb', line 7 def app @app end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vx/builder/script/prepare.rb', line 12 def call(env) name = env.task.name deploy_key = env.task.deploy_key repo_path = "${VX_ROOT}/code/#{name}" data_path = "${VX_ROOT}/data/#{name}" key_file = "#{data_path}/key" git_ssh_file = "#{data_path}/git_ssh" sha = env.task.sha scm = build_scm(env, sha, repo_path) git_ssh = scm.git_ssh_content(deploy_key && "#{key_file}") env.init.tap do |i| i << 'export VX_ROOT=$(pwd)' i << "mkdir -p #{data_path}" i << "mkdir -p #{repo_path}" if deploy_key i << upload_sh_command(key_file, deploy_key) i << "chmod 0600 #{key_file}" i << "export VX_PRIVATE_KEY=#{key_file}" end i << upload_sh_command(git_ssh_file, git_ssh) i << "chmod 0750 #{git_ssh_file}" i << "export GIT_SSH=#{git_ssh_file}" i << scm.fetch_cmd i << "unset GIT_SSH" i << 'echo "Starting SSH Agent"' i << 'eval "$(ssh-agent)"' i << "ssh-add $VX_PRIVATE_KEY" i << "cd #{repo_path}" end env.after_script_init.tap do |i| i << 'export VX_ROOT=$(pwd)' i << "cd #{repo_path}" end app.call env end |