Hudson is now Jenkins. Ergo hudson-war is now jenkins-war

This commit is contained in:
Charles Lowell 2011-02-03 09:57:16 -06:00
parent 9ef9385bd9
commit 294bbb3ca7
5 changed files with 69 additions and 69 deletions

View File

@ -2,44 +2,44 @@
#### 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
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
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?
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
/Users/cowboyd/.rvm/gems/ruby-1.8.7-p174@hudson.war/gems/hudson-war-1.391/lib/hudson/hudson.war
$ jenkins.war location
/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.
$ hudson.war unpack /tmp/hudson.war.exploded
$ jenkins.war unpack /tmp/jenkins.war.exploded
It can copy itself anywhere
$ hudson.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
$ jenkins.war cp 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:
$ hudson.war classpath
/Users/cowboyd/.hudson/wars/1.391/WEB-INF/lib/hudson-core-1.391.jar
$ jenkins.war classpath
/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.

View File

@ -11,9 +11,9 @@ def render(src, dest, use_binding = binding)
end
task :gem, :version do |t, options|
hudson_version = options.version
raise "invalid version number: #{options.version}" unless hudson_version.to_f > 0
directory gem_dir = "pkg/#{hudson_version}"
jenkins_version = options.version
raise "invalid version number: #{options.version}" unless jenkins_version.to_f > 0
directory gem_dir = "pkg/#{jenkins_version}"
outs = INS.map do |f|
filename = File.join(f.split('/')[1..-1])
directory dest_dir = File.join(gem_dir, File.dirname(filename))
@ -21,28 +21,28 @@ task :gem, :version do |t, options|
render f, out.name, binding
end
end
directory war_dir = "#{gem_dir}/lib/hudson"
warfile = file("#{war_dir}/hudson.war" => war_dir) do |f|
directory war_dir = "#{gem_dir}/lib/jenkins"
warfile = file("#{war_dir}/jenkins.war" => war_dir) do |f|
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
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|
s.name = "hudson-war"
s.version = hudson_version
s.name = "jenkins-war"
s.version = jenkins_version
s.platform = Gem::Platform::RUBY
s.authors = ["Charles Lowell"]
s.email = ["cowboyd@thefrontside.net"]
s.homepage = "http://rubygems.org/gems/hudson-war"
s.summary = "fetch and use a specific hudson 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.rubyforge_project = "hudson-war"
s.homepage = "http://rubygems.org/gems/jenkins-war"
s.summary = "fetch and use a specific jenkins version with rubygems"
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 = "jenkins-war"
# s.files = `git ls-files`.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"]
sh "touch #{f.name}"
sh "rm -rf #{gem_dir}/*.gem"
@ -55,7 +55,7 @@ task :gem, :version do |t, options|
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
Gem::Builder.new(eval(File.read(File.basename(gemspec.name)))).build
end
@ -65,12 +65,12 @@ end
task :install, :version do |t, options|
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
task :push, :version do |t, options|
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
task :clean do

View File

@ -2,22 +2,22 @@
require 'optparse'
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({
:home => File.join(ENV['HOME'], ".hudson", "server"),
:home => File.join(ENV['HOME'], ".jenkins", "server"),
:port => 3001,
:control => 3002,
:daemon => false,
:kill => false
})
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("-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("--daemon") {options.daemon = true}
parser.on("-k", "--kill") {options.kill = true}
@ -28,13 +28,13 @@ help = proc do |cmd|
if cmd && help.respond_to?(cmd)
puts help.send(cmd)
else
puts "usage: hudson.war COMMAND [OPTIONS]"
puts " hudson.war help command"
puts " hudson.war version"
puts " hudson.war unpack DESTINATION"
puts " hudson.war classpath"
puts " hudson.war cp DESTINATION"
puts " hudson.war server [OPTIONS]"
puts "usage: jenkins.war COMMAND [OPTIONS]"
puts " jenkins.war help command"
puts " jenkins.war version"
puts " jenkins.war unpack DESTINATION"
puts " jenkins.war classpath"
puts " jenkins.war cp DESTINATION"
puts " jenkins.war server [OPTIONS]"
puts ""
end
end
@ -45,38 +45,38 @@ class Help
end
def help
<<-HERE
Usage: hudson.war help COMMAND
Usage: jenkins.war help COMMAND
shows help for the specified command
HERE
end
def version
<<-HERE
Usage: hudson.war version
displays the version of hudson represented by this war
Usage: jenkins.war version
displays the version of jenkins represented by this war
HERE
end
def unpack
<<-HERE
Usage: hudson.war unpack DESTINATION
unpack the hudson war to directory at DESTINATION
Usage: jenkins.war unpack DESTINATION
unpack the jenkins war to directory at DESTINATION
HERE
end
def classpath
<<-HERE
Usage: hudson.war classpath
return a classpath for hudson core which can be used for a javac invocation
Usage: jenkins.war classpath
return a classpath for jenkins core which can be used for a javac invocation
HERE
end
def cp
<<-HERE
Usage: hudson.war cp PATH
copy the hudson.war file to PATH
Usage: jenkins.war cp PATH
copy the jenkins.war file to PATH
HERE
end
def location
<<-HERE
Usage: hudson.war location
prints the actual location on the file system of the hudson.war
Usage: jenkins.war location
prints the actual location on the file system of the jenkins.war
HERE
end
def server
@ -85,7 +85,7 @@ HERE
end
war = Hudson::War
war = Jenkins::War
case cmd = ARGV.shift
when "version", "-v", "--version"
puts war::VERSION

View File

@ -1,8 +1,8 @@
require 'fileutils'
module Hudson
module Jenkins
module War
VERSION = '<%= hudson_version %>'
LOCATION = File.expand_path(File.join(File.dirname(__FILE__), "hudson.war"))
VERSION = '<%= jenkins_version %>'
LOCATION = File.expand_path(File.join(File.dirname(__FILE__), "jenkins.war"))
module_function
@ -22,7 +22,7 @@ module Hudson
end
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
control = options.control.to_i || 3002
daemon = options.daemon
@ -49,9 +49,9 @@ module Hudson
end
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)
"#{dest_dir}/WEB-INF/lib/hudson-core-#{VERSION}.jar"
"#{dest_dir}/WEB-INF/lib/jenkins-core-#{VERSION}.jar"
else
FileUtils.mkdir_p(dest_dir)
unpack(dest_dir, [])

View File

@ -5,21 +5,21 @@ require 'bundler/setup'
require 'restclient'
require 'json'
print "latest hudson version..."
hudson_metadata = JSON.parse RestClient.get("http://updates.hudson-labs.org/update-center.json").split("\n")[1..-2].join("\n")
print "latest jenkins version..."
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..."
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']
if current_hudson_version > current_gem_version
if current_jenkins_version > current_gem_version
puts "upgrading..."
$stdout.flush
exec "rake push[#{current_hudson_version}]"
exec "rake push[#{current_jenkins_version}]"
else
puts "no need to upgrade. current gem is the latest"
end