jenkins-war 1.396

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'ostruct'
5
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/jenkins/war')
6
+
7
+
8
+
9
+
10
+ options = OpenStruct.new({
11
+ :home => File.join(ENV['HOME'], ".jenkins", "server"),
12
+ :port => 3001,
13
+ :control => 3002,
14
+ :daemon => false,
15
+ :kill => false
16
+ })
17
+ parser = OptionParser.new
18
+ parser.banner = "Usage: jenkins.war server [options]"
19
+ parser.on("--home DIR", String, "use this directory to store server data") {|dir| options.home = dir}
20
+ parser.on("-p", "--port PORT", Integer, "run jenkins server on this port") {|port| options.port = port}
21
+ parser.on("-c", "--control PORT", Integer, "set the shutdown/control port") {|control| options.control = control}
22
+ parser.on("--daemon") {options.daemon = true}
23
+ parser.on("-k", "--kill") {options.kill = true}
24
+ parser.on("--logfile PATH", String, "redirect log messages to this file") {|path| options.logfile = path}
25
+
26
+ help = proc do |cmd|
27
+ help = Help.new(parser)
28
+ if cmd && help.respond_to?(cmd)
29
+ puts help.send(cmd)
30
+ else
31
+ puts "usage: jenkins.war COMMAND [OPTIONS]"
32
+ puts " jenkins.war help command"
33
+ puts " jenkins.war version"
34
+ puts " jenkins.war unpack DESTINATION"
35
+ puts " jenkins.war classpath"
36
+ puts " jenkins.war cp DESTINATION"
37
+ puts " jenkins.war server [OPTIONS]"
38
+ puts ""
39
+ end
40
+ end
41
+
42
+ class Help
43
+ def initialize(server_options)
44
+ @server_options = server_options
45
+ end
46
+ def help
47
+ <<-HERE
48
+ Usage: jenkins.war help COMMAND
49
+ shows help for the specified command
50
+ HERE
51
+ end
52
+ def version
53
+ <<-HERE
54
+ Usage: jenkins.war version
55
+ displays the version of jenkins represented by this war
56
+ HERE
57
+ end
58
+ def unpack
59
+ <<-HERE
60
+ Usage: jenkins.war unpack DESTINATION
61
+ unpack the jenkins war to directory at DESTINATION
62
+ HERE
63
+ end
64
+ def classpath
65
+ <<-HERE
66
+ Usage: jenkins.war classpath
67
+ return a classpath for jenkins core which can be used for a javac invocation
68
+ HERE
69
+ end
70
+ def cp
71
+ <<-HERE
72
+ Usage: jenkins.war cp PATH
73
+ copy the jenkins.war file to PATH
74
+ HERE
75
+ end
76
+ def location
77
+ <<-HERE
78
+ Usage: jenkins.war location
79
+ prints the actual location on the file system of the jenkins.war
80
+ HERE
81
+ end
82
+ def server
83
+ @server_options.to_s
84
+ end
85
+ end
86
+
87
+
88
+ war = Jenkins::War
89
+ case cmd = ARGV.shift
90
+ when "version", "-v", "--version"
91
+ puts war::VERSION
92
+ exit
93
+ when 'unpack'
94
+ dest = ARGV.first
95
+ war.unpack(dest)
96
+ when 'classpath'
97
+ puts war.classpath
98
+ when 'cp'
99
+ dest = ARGV.first
100
+ war.cp dest
101
+ when 'server'
102
+ parser.parse(ARGV)
103
+ war.server(options)
104
+ when "help", "-h", "--help"
105
+ help[ARGV.first]
106
+ when "location"
107
+ puts war::LOCATION
108
+ else
109
+ help[nil]
110
+ end
111
+
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{jenkins-war}
5
+ s.version = "1.396"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Charles Lowell"]
9
+ s.date = %q{2011-02-03}
10
+ s.default_executable = %q{jenkins.war}
11
+ s.description = %q{download and install a specific version of the jenkins war file which can be used for either running a server, or for plugin development}
12
+ s.email = ["cowboyd@thefrontside.net"]
13
+ s.executables = ["jenkins.war"]
14
+ s.files = ["bin", "bin/jenkins.war", "jenkins-war.gemspec", "lib", "lib/jenkins", "lib/jenkins/jenkins.war", "lib/jenkins/war.rb"]
15
+ s.homepage = %q{http://rubygems.org/gems/jenkins-war}
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{jenkins-war}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{fetch and use a specific jenkins version with rubygems}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
Binary file
@@ -0,0 +1,68 @@
1
+ require 'fileutils'
2
+ module Jenkins
3
+ module War
4
+ VERSION = '1.396'
5
+ LOCATION = File.expand_path(File.join(File.dirname(__FILE__), "jenkins.war"))
6
+
7
+ module_function
8
+
9
+ def unpack(dest_dir, output = $stdout)
10
+ target = File.dirname(dest_dir).tap do |dir_of_dest_dir|
11
+ raise "'#{dir_of_dest_dir}' is not a directory" unless File.directory?(dir_of_dest_dir)
12
+ end
13
+ FileUtils.mkdir_p dest_dir
14
+ Dir.chdir(dest_dir) do
15
+ sh "jar xvf #{LOCATION}", output
16
+ end
17
+ end
18
+
19
+ def cp(dest, output = $stdout)
20
+ FileUtils.cp(LOCATION, dest)
21
+ output << "copied #{LOCATION} -> #{dest}\n"
22
+ end
23
+
24
+ def server(options, output = $stdout)
25
+ home = options.home || File.join(ENV['HOME'], ".jenkins", "server")
26
+ port = options.port.to_i || 3001
27
+ control = options.control.to_i || 3002
28
+ daemon = options.daemon
29
+ kill = options.kill
30
+ logfile = options.logfile
31
+
32
+ if kill
33
+ require 'socket'
34
+ TCPSocket.open("localhost", control) do |sock|
35
+ sock.write("0")
36
+ end
37
+ else
38
+ javatmp = File.join(home, "javatmp")
39
+ FileUtils.mkdir_p javatmp
40
+ ENV['HUDSON_HOME'] = home
41
+ cmd = ["java", "-Djava.io.tmpdir=#{javatmp}", "-jar", LOCATION]
42
+ cmd << "--daemon" if daemon
43
+ cmd << "--logfile=#{File.expand_path(logfile)}" if logfile
44
+ cmd << "--httpPort=#{port}"
45
+ cmd << "--controlPort=#{control}"
46
+ output << "#{cmd.join(" ")}\n"
47
+ exec(*cmd)
48
+ end
49
+ end
50
+
51
+ def classpath
52
+ dest_dir = File.join(ENV['HOME'], '.jenkins', 'wars', VERSION)
53
+ if File.directory?(dest_dir)
54
+ "#{dest_dir}/WEB-INF/lib/jenkins-core-#{VERSION}.jar"
55
+ else
56
+ FileUtils.mkdir_p(dest_dir)
57
+ unpack(dest_dir, [])
58
+ classpath
59
+ end
60
+ end
61
+
62
+ def sh(command, output = $stdout)
63
+ output << command + "\n"
64
+ output << result = `#{command}`
65
+ raise result unless $?.success?
66
+ end
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jenkins-war
3
+ version: !ruby/object:Gem::Version
4
+ hash: 791
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 396
9
+ version: "1.396"
10
+ platform: ruby
11
+ authors:
12
+ - Charles Lowell
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-03 00:00:00 -06:00
18
+ default_executable: jenkins.war
19
+ dependencies: []
20
+
21
+ description: download and install a specific version of the jenkins war file which can be used for either running a server, or for plugin development
22
+ email:
23
+ - cowboyd@thefrontside.net
24
+ executables:
25
+ - jenkins.war
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - bin/jenkins.war
32
+ - jenkins-war.gemspec
33
+ - lib/jenkins/jenkins.war
34
+ - lib/jenkins/war.rb
35
+ has_rdoc: true
36
+ homepage: http://rubygems.org/gems/jenkins-war
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project: jenkins-war
65
+ rubygems_version: 1.3.7
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: fetch and use a specific jenkins version with rubygems
69
+ test_files: []
70
+