Class: Jenkins::Launcher
- Inherits:
-
Object
- Object
- Jenkins::Launcher
- Defined in:
- lib/jenkins/launcher.rb
Overview
Launch processes on build slaves. No functionality is currently exposed
Defined Under Namespace
Classes: Proc
Instance Attribute Summary collapse
-
#native ⇒ Object
readonly
the native hudson.Launcher object.
Instance Method Summary collapse
-
#execute(*args) ⇒ Object
execute( command… [,options]) -> fixnum.
-
#initialize(native = nil) ⇒ Launcher
constructor
A new instance of Launcher.
-
#spawn(*args) ⇒ Object
spawn( command… [,options]) -> proc.
Constructor Details
#initialize(native = nil) ⇒ Launcher
Returns a new instance of Launcher.
41 42 43 |
# File 'lib/jenkins/launcher.rb', line 41 def initialize(native = nil) @native = native end |
Instance Attribute Details
#native ⇒ Object (readonly)
the native hudson.Launcher object
39 40 41 |
# File 'lib/jenkins/launcher.rb', line 39 def native @native end |
Instance Method Details
#execute(*args) ⇒ Object
execute( command… [,options]) -> fixnum
46 47 48 |
# File 'lib/jenkins/launcher.rb', line 46 def execute(*args) spawn(*args).join end |
#spawn(*args) ⇒ Object
spawn( command… [,options]) -> proc
51 52 53 54 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 83 84 85 86 87 |
# File 'lib/jenkins/launcher.rb', line 51 def spawn(*args) env, cmd, = scan_args(args) starter = @native.launch() starter.envs(env) if opt_chdir = [:chdir] starter.pwd(opt_chdir.to_s) end if opt_in = [:in] starter.stdin(opt_in.to_inputstream) end if opt_out = [:out] if opt_out.is_a?(Jenkins::Model::Listener) starter.stdout(Jenkins::Plugin.instance.export(opt_out)) else starter.stdout(opt_out.to_outputstream) end end if opt_err = [:err] starter.stderr(opt_err.to_outputstream) end case cmd when Array starter.cmds(cmd) else begin # when we are on 1.432, we can use cmdAsSingleString starter.cmdAsSingleString(cmd.to_s) rescue NoMethodError # http://d.hatena.ne.jp/sikakura/20110324/1300977208 is doing # Arrays.asList(str.split(" ")) which should be wrong. require 'shellwords' starter.cmds(*Shellwords.split(cmd.to_s)) end end Proc.new(starter.start()) end |