Module: Jenkins::War
- Defined in:
- lib/jenkins/war.rb
Constant Summary collapse
- VERSION =
'1.514'
- LOCATION =
File.(File.join(File.dirname(__FILE__), "jenkins.war"))
Class Method Summary collapse
- .classpath ⇒ Object
- .cp(dest, output = $stdout) ⇒ Object
- .server(options, output = $stdout) ⇒ Object
- .sh(command, output = $stdout) ⇒ Object
- .unpack(dest_dir, output = $stdout) ⇒ Object
Class Method Details
.classpath ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jenkins/war.rb', line 51 def classpath dest_dir = File.join(ENV['HOME'], '.jenkins', 'wars', VERSION) if File.directory?(dest_dir) "#{dest_dir}/WEB-INF/lib/jenkins-core-#{VERSION}.jar" else FileUtils.mkdir_p(dest_dir) unpack(dest_dir, []) classpath end end |
.cp(dest, output = $stdout) ⇒ Object
19 20 21 22 |
# File 'lib/jenkins/war.rb', line 19 def cp(dest, output = $stdout) FileUtils.cp(LOCATION, dest) output << "copied #{LOCATION} -> #{dest}\n" end |
.server(options, output = $stdout) ⇒ Object
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 |
# File 'lib/jenkins/war.rb', line 24 def server(, output = $stdout) home = .home || File.join(ENV['HOME'], ".jenkins", "server") port = .port.to_i || 3001 control = .control.to_i || 3002 daemon = .daemon kill = .kill logfile = .logfile if kill require 'socket' TCPSocket.open("localhost", control) do |sock| sock.write("0") end else javatmp = File.join(home, "javatmp") FileUtils.mkdir_p javatmp ENV['HUDSON_HOME'] = home cmd = ["java", "-Djava.io.tmpdir=#{javatmp}", "-jar", LOCATION] cmd << "--daemon" if daemon cmd << "--logfile=#{File.(logfile)}" if logfile cmd << "--httpPort=#{port}" cmd << "--controlPort=#{control}" output << "#{cmd.join(" ")}\n" exec(*cmd) end end |
.sh(command, output = $stdout) ⇒ Object
62 63 64 65 66 |
# File 'lib/jenkins/war.rb', line 62 def sh(command, output = $stdout) output << command + "\n" output << result = `#{command}` raise result unless $?.success? end |
.unpack(dest_dir, output = $stdout) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/jenkins/war.rb', line 9 def unpack(dest_dir, output = $stdout) target = File.dirname(dest_dir).tap do |dir_of_dest_dir| raise "'#{dir_of_dest_dir}' is not a directory" unless File.directory?(dir_of_dest_dir) end FileUtils.mkdir_p dest_dir Dir.chdir(dest_dir) do sh "jar xvf #{LOCATION}", output end end |