Skip to content

Commit

Permalink
Hudson is now Jenkins. Ergo hudson-war is now jenkins-war
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboyd committed Feb 3, 2011
1 parent 9ef9385 commit 294bbb3
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 69 deletions.
34 changes: 17 additions & 17 deletions README.md
Expand Up @@ -2,44 +2,44 @@


#### What? #### What?


The hudson wargemmer consists of two parts: a Rake task for turning a hudson war file The jenkins wargemmer consists of two parts: a Rake task for turning a jenkins war file
(__W.__eb __A.__ __R.__chive for those not familiar with java lingo) into a distributable rubygem, and a cron task for creating (__W.__eb __A.__ __R.__chive for those not familiar with java lingo) into a distributable rubygem, and a cron task for creating
a new version of the gem, whenever a new hudson version comes out. a new version of the gem, whenever a new jenkins version comes out.


The script polls the hudson update center and checks to see if there is a newer version of the hudson distribution that The script polls the jenkins update center and checks to see if there is a newer version of the jenkins distribution that
has not yet been gemmed up and if not, then bundles it and pushes it to [rubygems.org](http://rubygems.org) as a gem named has not yet been gemmed up and if not, then bundles it and pushes it to [rubygems.org](http://rubygems.org) as a gem named
hudson-war. jenkins-war.


The generated gem has the same version number as the hudson distribution itself. So if you want the 1.386 distribution, then you would do a The generated gem has the same version number as the jenkins distribution itself. So if you want the 1.386 distribution, then you would do a


gem install hudson-war --version 1.386 gem install jenkins-war --version 1.386


#### How? #### How?


In addition to the war file long with the The hudson-war gem comes with an executable script `hudson.war` to help you leverage your hudson distribution. In addition to the war file long with the The jenkins-war gem comes with an executable script `jenkins.war` to help you leverage your jenkins distribution.


Without any arguments, it returns the location of the hudson warfile itself: Without any arguments, it returns the location of the jenkins warfile itself:


$ hudson.war location $ jenkins.war location
/Users/cowboyd/.rvm/gems/ruby-1.8.7-p174@hudson.war/gems/hudson-war-1.391/lib/hudson/hudson.war /Users/cowboyd/.rvm/gems/ruby-1.8.7-p174@jenkins.war/gems/jenkins-war-1.391/lib/jenkins/jenkins.war


It can unpack itself to a given directory. This is useful if you want to extract certain assets such as classfiles, annotations, configurations from it. It can unpack itself to a given directory. This is useful if you want to extract certain assets such as classfiles, annotations, configurations from it.


$ hudson.war unpack /tmp/hudson.war.exploded $ jenkins.war unpack /tmp/jenkins.war.exploded


It can copy itself anywhere It can copy itself anywhere


$ hudson.war cp tmp $ jenkins.war cp tmp
copied /Users/cowboyd/.rvm/gems/ruby-1.8.7-p174@hudson.war/gems/hudson-war-1.391/lib/hudson/hudson.war -> tmp copied /Users/cowboyd/.rvm/gems/ruby-1.8.7-p174@jenkins.war/gems/jenkins-war-1.391/lib/jenkins/jenkins.war -> tmp


Or if you want the classpath: Or if you want the classpath:


$ hudson.war classpath $ jenkins.war classpath
/Users/cowboyd/.hudson/wars/1.391/WEB-INF/lib/hudson-core-1.391.jar /Users/cowboyd/.jenkins/wars/1.391/WEB-INF/lib/jenkins-core-1.391.jar


You can even run a test server with your shiny hudson war file. You can even run a test server with your shiny jenkins war file.


$ hudson.war server $ jenkins.war server


All of these functions can be accessed from ruby code via the `Hudson::War` module. All of these functions can be accessed from ruby code via the `Hudson::War` module.


Expand Down
34 changes: 17 additions & 17 deletions Rakefile
Expand Up @@ -11,38 +11,38 @@ def render(src, dest, use_binding = binding)
end end


task :gem, :version do |t, options| task :gem, :version do |t, options|
hudson_version = options.version jenkins_version = options.version
raise "invalid version number: #{options.version}" unless hudson_version.to_f > 0 raise "invalid version number: #{options.version}" unless jenkins_version.to_f > 0
directory gem_dir = "pkg/#{hudson_version}" directory gem_dir = "pkg/#{jenkins_version}"
outs = INS.map do |f| outs = INS.map do |f|
filename = File.join(f.split('/')[1..-1]) filename = File.join(f.split('/')[1..-1])
directory dest_dir = File.join(gem_dir, File.dirname(filename)) directory dest_dir = File.join(gem_dir, File.dirname(filename))
file(File.join(dest_dir, File.basename(filename, '.in')) => [f, dest_dir]) do |out| file(File.join(dest_dir, File.basename(filename, '.in')) => [f, dest_dir]) do |out|
render f, out.name, binding render f, out.name, binding
end end
end end
directory war_dir = "#{gem_dir}/lib/hudson" directory war_dir = "#{gem_dir}/lib/jenkins"
warfile = file("#{war_dir}/hudson.war" => war_dir) do |f| warfile = file("#{war_dir}/jenkins.war" => war_dir) do |f|
Dir.chdir(File.dirname(f.name)) do Dir.chdir(File.dirname(f.name)) do
sh "wget http://updates.hudson-labs.org/download/war/#{hudson_version}/hudson.war" sh "wget http://updates.jenkins-ci.org/download/war/#{jenkins_version}/jenkins.war"
end end
end end


gemspec = file("#{gem_dir}/hudson-war.gemspec" => outs + [warfile]) do |f| gemspec = file("#{gem_dir}/jenkins-war.gemspec" => outs + [warfile]) do |f|
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "hudson-war" s.name = "jenkins-war"
s.version = hudson_version s.version = jenkins_version
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.authors = ["Charles Lowell"] s.authors = ["Charles Lowell"]
s.email = ["cowboyd@thefrontside.net"] s.email = ["cowboyd@thefrontside.net"]
s.homepage = "http://rubygems.org/gems/hudson-war" s.homepage = "http://rubygems.org/gems/jenkins-war"
s.summary = "fetch and use a specific hudson version with rubygems" s.summary = "fetch and use a specific jenkins version with rubygems"
s.description = "download and install a specific version of the hudson war file which can be used for either running a server, or for plugin development" s.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"
s.rubyforge_project = "hudson-war" s.rubyforge_project = "jenkins-war"


# s.files = `git ls-files`.split("\n") # s.files = `git ls-files`.split("\n")
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") # s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = ['hudson.war'] s.executables = ['jenkins.war']
s.require_paths = ["lib"] s.require_paths = ["lib"]
sh "touch #{f.name}" sh "touch #{f.name}"
sh "rm -rf #{gem_dir}/*.gem" sh "rm -rf #{gem_dir}/*.gem"
Expand All @@ -55,7 +55,7 @@ task :gem, :version do |t, options|
end end
end end


gem = file "#{gem_dir}/hudson-war-#{hudson_version}.gem" => gemspec do gem = file "#{gem_dir}/jenkins-war-#{jenkins_version}.gem" => gemspec do
Dir.chdir(gem_dir) do Dir.chdir(gem_dir) do
Gem::Builder.new(eval(File.read(File.basename(gemspec.name)))).build Gem::Builder.new(eval(File.read(File.basename(gemspec.name)))).build
end end
Expand All @@ -65,12 +65,12 @@ end


task :install, :version do |t, options| task :install, :version do |t, options|
Rake::Task["gem"].invoke(options.version) Rake::Task["gem"].invoke(options.version)
sh "gem install pkg/#{options.version}/hudson-war-#{options.version}.gem" sh "gem install pkg/#{options.version}/jenkins-war-#{options.version}.gem"
end end


task :push, :version do |t, options| task :push, :version do |t, options|
Rake::Task["gem"].invoke(options.version) Rake::Task["gem"].invoke(options.version)
sh "gem push pkg/#{options.version}/hudson-war-#{options.version}.gem" sh "gem push pkg/#{options.version}/jenkins-war-#{options.version}.gem"
end end


task :clean do task :clean do
Expand Down
46 changes: 23 additions & 23 deletions template/bin/hudson.war.in → template/bin/jenkins.war.in
Expand Up @@ -2,22 +2,22 @@


require 'optparse' require 'optparse'
require 'ostruct' require 'ostruct'
require File.expand_path(File.dirname(__FILE__) + '/../lib/hudson/war') require File.expand_path(File.dirname(__FILE__) + '/../lib/jenkins/war')








options = OpenStruct.new({ options = OpenStruct.new({
:home => File.join(ENV['HOME'], ".hudson", "server"), :home => File.join(ENV['HOME'], ".jenkins", "server"),
:port => 3001, :port => 3001,
:control => 3002, :control => 3002,
:daemon => false, :daemon => false,
:kill => false :kill => false
}) })
parser = OptionParser.new parser = OptionParser.new
parser.banner = "Usage: hudson.war server [options]" parser.banner = "Usage: jenkins.war server [options]"
parser.on("--home DIR", String, "use this directory to store server data") {|dir| options.home = dir} parser.on("--home DIR", String, "use this directory to store server data") {|dir| options.home = dir}
parser.on("-p", "--port PORT", Integer, "run hudson server on this port") {|port| options.port = port} parser.on("-p", "--port PORT", Integer, "run jenkins server on this port") {|port| options.port = port}
parser.on("-c", "--control PORT", Integer, "set the shutdown/control port") {|control| options.control = control} parser.on("-c", "--control PORT", Integer, "set the shutdown/control port") {|control| options.control = control}
parser.on("--daemon") {options.daemon = true} parser.on("--daemon") {options.daemon = true}
parser.on("-k", "--kill") {options.kill = true} parser.on("-k", "--kill") {options.kill = true}
Expand All @@ -28,13 +28,13 @@ help = proc do |cmd|
if cmd && help.respond_to?(cmd) if cmd && help.respond_to?(cmd)
puts help.send(cmd) puts help.send(cmd)
else else
puts "usage: hudson.war COMMAND [OPTIONS]" puts "usage: jenkins.war COMMAND [OPTIONS]"
puts " hudson.war help command" puts " jenkins.war help command"
puts " hudson.war version" puts " jenkins.war version"
puts " hudson.war unpack DESTINATION" puts " jenkins.war unpack DESTINATION"
puts " hudson.war classpath" puts " jenkins.war classpath"
puts " hudson.war cp DESTINATION" puts " jenkins.war cp DESTINATION"
puts " hudson.war server [OPTIONS]" puts " jenkins.war server [OPTIONS]"
puts "" puts ""
end end
end end
Expand All @@ -45,38 +45,38 @@ class Help
end end
def help def help
<<-HERE <<-HERE
Usage: hudson.war help COMMAND Usage: jenkins.war help COMMAND
shows help for the specified command shows help for the specified command
HERE HERE
end end
def version def version
<<-HERE <<-HERE
Usage: hudson.war version Usage: jenkins.war version
displays the version of hudson represented by this war displays the version of jenkins represented by this war
HERE HERE
end end
def unpack def unpack
<<-HERE <<-HERE
Usage: hudson.war unpack DESTINATION Usage: jenkins.war unpack DESTINATION
unpack the hudson war to directory at DESTINATION unpack the jenkins war to directory at DESTINATION
HERE HERE
end end
def classpath def classpath
<<-HERE <<-HERE
Usage: hudson.war classpath Usage: jenkins.war classpath
return a classpath for hudson core which can be used for a javac invocation return a classpath for jenkins core which can be used for a javac invocation
HERE HERE
end end
def cp def cp
<<-HERE <<-HERE
Usage: hudson.war cp PATH Usage: jenkins.war cp PATH
copy the hudson.war file to PATH copy the jenkins.war file to PATH
HERE HERE
end end
def location def location
<<-HERE <<-HERE
Usage: hudson.war location Usage: jenkins.war location
prints the actual location on the file system of the hudson.war prints the actual location on the file system of the jenkins.war
HERE HERE
end end
def server def server
Expand All @@ -85,7 +85,7 @@ HERE
end end




war = Hudson::War war = Jenkins::War
case cmd = ARGV.shift case cmd = ARGV.shift
when "version", "-v", "--version" when "version", "-v", "--version"
puts war::VERSION puts war::VERSION
Expand Down
12 changes: 6 additions & 6 deletions template/lib/hudson/war.rb.in → template/lib/jenkins/war.rb.in
@@ -1,8 +1,8 @@
require 'fileutils' require 'fileutils'
module Hudson module Jenkins
module War module War
VERSION = '<%= hudson_version %>' VERSION = '<%= jenkins_version %>'
LOCATION = File.expand_path(File.join(File.dirname(__FILE__), "hudson.war")) LOCATION = File.expand_path(File.join(File.dirname(__FILE__), "jenkins.war"))


module_function module_function


Expand All @@ -22,7 +22,7 @@ module Hudson
end end


def server(options, output = $stdout) def server(options, output = $stdout)
home = options.home || File.join(ENV['HOME'], ".hudson", "server") home = options.home || File.join(ENV['HOME'], ".jenkins", "server")
port = options.port.to_i || 3001 port = options.port.to_i || 3001
control = options.control.to_i || 3002 control = options.control.to_i || 3002
daemon = options.daemon daemon = options.daemon
Expand All @@ -49,9 +49,9 @@ module Hudson
end end


def classpath def classpath
dest_dir = File.join(ENV['HOME'], '.hudson', 'wars', VERSION) dest_dir = File.join(ENV['HOME'], '.jenkins', 'wars', VERSION)
if File.directory?(dest_dir) if File.directory?(dest_dir)
"#{dest_dir}/WEB-INF/lib/hudson-core-#{VERSION}.jar" "#{dest_dir}/WEB-INF/lib/jenkins-core-#{VERSION}.jar"
else else
FileUtils.mkdir_p(dest_dir) FileUtils.mkdir_p(dest_dir)
unpack(dest_dir, []) unpack(dest_dir, [])
Expand Down
12 changes: 6 additions & 6 deletions wargemmer
Expand Up @@ -5,21 +5,21 @@ require 'bundler/setup'
require 'restclient' require 'restclient'
require 'json' require 'json'


print "latest hudson version..." print "latest jenkins version..."
hudson_metadata = JSON.parse RestClient.get("http://updates.hudson-labs.org/update-center.json").split("\n")[1..-2].join("\n") jenkins_metadata = JSON.parse RestClient.get("http://updates.jenkins-ci.org/update-center.json").split("\n")[1..-2].join("\n")


puts current_hudson_version = hudson_metadata['core']['version'] puts current_jenkins_version = jenkins_metadata['core']['version']


print "latest gem version..." print "latest gem version..."


gem_metadata = JSON.parse RestClient.get("http://rubygems.org/api/v1/gems/hudson-war.json") gem_metadata = JSON.parse RestClient.get("http://rubygems.org/api/v1/gems/jenkins-war.json")


puts current_gem_version = gem_metadata['version'] puts current_gem_version = gem_metadata['version']


if current_hudson_version > current_gem_version if current_jenkins_version > current_gem_version
puts "upgrading..." puts "upgrading..."
$stdout.flush $stdout.flush
exec "rake push[#{current_hudson_version}]" exec "rake push[#{current_jenkins_version}]"
else else
puts "no need to upgrade. current gem is the latest" puts "no need to upgrade. current gem is the latest"
end end
Expand Down

0 comments on commit 294bbb3

Please sign in to comment.