Skip to content

Commit

Permalink
Updating README, cleaning up code from the original branch from the c…
Browse files Browse the repository at this point in the history
…apistrano-scm-jenkins project. Thx much to https://github.com/lidaobing for the inspiration.
  • Loading branch information
knightlabs committed Apr 17, 2012
1 parent 73acce3 commit f51eb90
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 185 deletions.
13 changes: 0 additions & 13 deletions NEWS.md

This file was deleted.

63 changes: 21 additions & 42 deletions README.md
@@ -1,52 +1,31 @@
# capistrano-scm-jenkins
# capistrano-scm-bamboo

With this plugin, you can use jenkins build artifact as a repository, and
deploy your build artifact with capistrano.
With this plugin, you can use Atlassian Bamboo build artifacts as a repository,
and deploy your build with Capistrano.

## INSTALL

gem install capistrano-scm-jenkins
gem install capistrano-scm-bamboo

## USAGE

a sample config/deploy.rb

require 'capistrano-scm-jenkins'

set :application, "example"
set :repository, "http://jenkins.example.com/job/example/"

set :scm, :jenkins

# uncomment following line if you want deploy unstable version
# set :jenkins_use_unstable, true

# jenkins username and password
# set :scm_username, ENV['JENKINS_USERNAME']
# set :scm_password, ENV['JENKINS_PASSWORD']
# or use the netrc support for curl
# set :jenkins_use_netrc, true
#
# if you use netrc, add the following line in your $HOME/.netrc
# machine jenkins.example.com login USERNAME password secret


set :user, 'lidaobing'
set :use_sudo, false
set :deploy_to, "/home/#{user}/apps/#{application}"

role :web, "test.example.com" # Your HTTP server, Apache/etc
role :app, "test.example.com" # This may be the same as your `Web` server
role :db, "test.example.com", :primary => true # This is where Rails migrations will run

for more information about capistrano, check https://github.com/capistrano/capistrano

### maven module

for the maven module, you should include the module name in your repository url. for example:

set :repository, "http://jenkins.example.com/job/example/com.example.helloworld$helloworld/"

Sample extract from config/deploy.rb

require 'capistrano-scm-bamboo'

set :application, "example"

set :scm, bamboo
set :repository, "http://bamboo.local/rest/api/latest"

set :scm_username, ENV['CAP_BUILD_USER'] || "build"
set :scm_passphrase, ENV['CAP_BUILD_PASS'] || Proc.new { Capistrano::CLI.password_prompt("Please enter the Bamboo password for '#{scm_username}': ") }

# If calling Cap from within Bamboo, these can be passed via -s options on the Cap call itself to override
set :plan_key, "PROJECT-PLAN"
set :build_number, "latest"
set :artifact, "artifact"

## LICENSE

Permission is hereby granted, free of charge, to any person obtaining
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano-scm-bamboo/version.rb
@@ -1,7 +1,7 @@
module Capistrano
module Scm
module Bamboo
VERSION = "1.0.4"
VERSION = "1.1.0"
end
end
end
107 changes: 0 additions & 107 deletions lib/capistrano/recipes/deploy/scm/bamboo.rb
Expand Up @@ -42,113 +42,6 @@ def diff(from, to=nil)
logger.info 'bamboo does not support diff'
'true'
end

private

# def authentication
# if variable(:jenkins_use_netrc)
# "--netrc"
# elsif variable(:scm_username) and variable(:scm_password)
# "--user '#{variable(:scm_username)}:#{variable(:scm_password)}'"
# else
# ""
# end
# end

# def use_unstable?
# !!variable(:jenkins_use_unstable)
# end

# def log_build_message(from, to=nil, message=nil)
# message = rss_all if message.nil?
# doc = REXML::Document.new(message).root
# logger.info ''
# logger.info "BUILD LOG"
# logger.info '========='
# REXML::XPath.each(doc,"./entry") do |entry|
# title = REXML::XPath.first(entry, "./title").text
# time = REXML::XPath.first(entry, "./updated").text
# build_number = get_build_number_from_rss_all_title(title).to_i
# if build_number > from.to_i and (to.nil? or build_number <= to.to_i)
# logger.info "#{time}\t#{title}"
# end
# end
# end

# def log_scm_message(from, to=nil, message=nil)
# message = rss_changelog if message.nil?
# doc = REXML::Document.new(message).root
# logger.info "SCM LOG"
# logger.info '======='
# REXML::XPath.each(doc,"./entry") do |entry|
# title = REXML::XPath.first(entry, "./title").text
# time = REXML::XPath.first(entry, "./updated").text
# content = REXML::XPath.first(entry, "./content").text
# build_number = get_build_number_from_rss_changelog_title(title).to_i
# if build_number > from.to_i and (to.nil? or build_number <= to.to_i)
# logger.info "#{time}\t#{title}"
# logger.info "#{content}"
# end
# end
# end

# def last_deploy_build(message = nil, opts={})
# message = rss_all if message.nil?
# use_unstable = opts[:use_unstable]
# use_unstable = use_unstable? if use_unstable.nil?
# doc = REXML::Document.new(message).root
# valid_end_strings = ['(back to normal)', '(stable)']
# if use_unstable
# valid_end_strings << '(unstable)'
# end
# REXML::XPath.each(doc,"./entry/title") do |title|
# title = title.text
# for x in valid_end_strings
# return get_build_number_from_rss_all_title(title) if title.end_with? x
# end
# end
# raise 'can not find a build suitable for deploy'
# end

# def auth_opts
# if jenkins_username and jenkins_password
# {:http_basic_authentication => [jenkins_username, jenkins_password]}
# else
# {}
# end
# end

# def artifact_zip_url(revision)
# "#{repository}/#{revision}/artifact/*zip*/archive.zip"
# end

# def jenkins_username
# @jenkins_username ||= begin
# if variable(:jenkins_use_netrc)
# rc = Net::Netrc.locate(jenkins_hostname)
# raise ".netrc missing or no entry found" if rc.nil?
# rc.login
# elsif variable(:scm_username)
# variable(:scm_username)
# else
# nil
# end
# end
# end

# def jenkins_password
# @jenkins_password ||= begin
# if variable(:jenkins_use_netrc)
# rc = Net::Netrc.locate(jenkins_hostname)
# raise ".netrc missing or no entry found" if rc.nil?
# rc.password
# elsif variable(:scm_password)
# variable(:scm_password)
# else
# nil
# end
# end
# end
end
end
end
Expand Down
22 changes: 0 additions & 22 deletions spec/capistrano/recipes/deploy/scm/bamboo_spec.rb
Expand Up @@ -6,27 +6,5 @@ module Capistrano::Deploy::SCM
before :each do
@bamboo = Bamboo.new
end

context "last_deploy_build" do
it "should support back to normal" do
msg = %Q{<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>estore-nginx all builds</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/estore-nginx/" rel="alternate"/><updated>2011-11-24T07:11:06Z</updated><author><name>Jenkins Server</name></author><id>urn:uuid:903deee0-7bfa-11db-9fe1-0800200c9a66</id><entry><title>estore-nginx #2 (back to normal)</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/estore-nginx/2/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:estore-nginx:2011-11-24_15-11-06</id><published>2011-11-24T07:11:06Z</published><updated>2011-11-24T07:11:06Z</updated></entry><entry><title>estore-nginx #1 (broken for a long time)</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/estore-nginx/1/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:estore-nginx:2011-11-24_15-09-18</id><published>2011-11-24T07:09:18Z</published><updated>2011-11-24T07:09:18Z</updated></entry></feed>}
@jenkins.send(:last_deploy_build, msg).should == '2'
end

it "should support stable" do
msg = %Q{<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>cerl all builds</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/cerl/" rel="alternate"/><updated>2011-11-17T05:17:58Z</updated><author><name>Jenkins Server</name></author><id>urn:uuid:903deee0-7bfa-11db-9fe1-0800200c9a66</id><entry><title>cerl #98 (stable)</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/cerl/98/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:cerl:2011-11-17_13-17-58</id><published>2011-11-17T05:17:58Z</published><updated>2011-11-17T05:17:58Z</updated></entry><entry><title>cerl #97 (stable)</title><link type="text/html" href="http://ci.eb.in.sdo.com/view/eStore/job/cerl/97/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:cerl:2011-11-12_18-27-58</id><published>2011-11-12T10:27:58Z</published><updated>2011-11-12T10:27:58Z</updated></entry></feed>}
@jenkins.send(:last_deploy_build, msg).should == '98'
end

it "should honor unstable" do
msg = %Q{<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>IndexCoordinator all builds</title><link type="text/html" href="http://ci.eb.in.sdo.com/job/IndexCoordinator/" rel="alternate"/><updated>2011-11-24T09:22:32Z</updated><author><name>Jenkins Server</name></author><id>urn:uuid:903deee0-7bfa-11db-9fe1-0800200c9a66</id><entry><title>IndexCoordinator #1450 (unstable)</title><link type="text/html" href="http://ci.eb.in.sdo.com/job/IndexCoordinator/1450/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:IndexCoordinator:2011-11-22_19-44-23</id><published>2011-11-22T11:44:23Z</published><updated>2011-11-22T11:44:23Z</updated></entry><entry><title>IndexCoordinator #1449 (back to normal)</title><link type="text/html" href="http://ci.eb.in.sdo.com/job/IndexCoordinator/1449/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:IndexCoordinator:2011-11-22_19-23-22</id><published>2011-11-22T11:23:22Z</published><updated>2011-11-22T11:23:22Z</updated></entry><entry><title>IndexCoordinator #1448 (broken since this build)</title><link type="text/html" href="http://ci.eb.in.sdo.com/job/IndexCoordinator/1448/" rel="alternate"/><id>tag:hudson.dev.java.net,2011:IndexCoordinator:2011-11-22_19-10-50</id><published>2011-11-22T11:10:50Z</published><updated>2011-11-22T11:10:50Z</updated></entry></feed>
}
@jenkins.send(:last_deploy_build, msg).should == '1449'
@jenkins.send(:last_deploy_build, msg, :use_unstable => true).should == '1450'
end
end
end
end

0 comments on commit f51eb90

Please sign in to comment.