Method: Cyclid::API::Plugins::Script#perform

Defined in:
app/cyclid/plugins/action/script.rb

#perform(log) ⇒ Object

Run the script action



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/cyclid/plugins/action/script.rb', line 55

def perform(log)
  begin
    # Export the environment data to the build host, if necesary
    env = @env % @ctx if @env
    @transport.export_env(env)

    # Add context data
    script = @script ** @ctx
    path = @path ** @ctx

    # Create an IO object containing the script and upload it to the
    # build host
    log.write("Uploading script to #{path}\n")

    io = StringIO.new(script)
    @transport.upload(io, path)

    # Execute the script
    log.write("Running script from #{path}...\n")
    success = @transport.exec("chmod +x #{path} && #{path}", sudo: @sudo)
  rescue KeyError => ex
    # Interpolation failed
    log.write "#{ex.message}\n"
    success = false
  end

  [success, @transport.exit_code]
end