Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the jenkins/hudson branch name #15

Merged
merged 2 commits into from May 22, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -27,6 +27,7 @@ gem 'github_api'


gem 'json' gem 'json'
gem 'nokogiri' gem 'nokogiri'
gem 'curb'


group :test do group :test do
gem 'rspec' gem 'rspec'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -8,6 +8,7 @@ GEM
awesome_print (1.0.2) awesome_print (1.0.2)
cinch (2.0.2) cinch (2.0.2)
coderay (1.0.6) coderay (1.0.6)
curb (0.8.0)
diff-lcs (1.1.3) diff-lcs (1.1.3)
fakefs (0.4.0) fakefs (0.4.0)
faraday (0.7.6) faraday (0.7.6)
Expand Down Expand Up @@ -64,6 +65,7 @@ DEPENDENCIES
activesupport activesupport
awesome_print awesome_print
cinch cinch
curb
fakefs fakefs
github_api github_api
hiredis hiredis
Expand Down
10 changes: 10 additions & 0 deletions plugins/hudson.rb
Expand Up @@ -6,6 +6,7 @@ class Hudson
autoload :Fetcher, 'hudson/fetcher' autoload :Fetcher, 'hudson/fetcher'
autoload :Reporter, 'hudson/reporter' autoload :Reporter, 'hudson/reporter'
autoload :TestRun, 'hudson/test_run' autoload :TestRun, 'hudson/test_run'
autoload :Config, 'hudson/config'


HYDRA = Typhoeus::Hydra.new HYDRA = Typhoeus::Hydra.new


Expand All @@ -16,6 +17,7 @@ class Hudson
match /#{FAILED} #{JOB}#{BUILD}$/, method: :failures match /#{FAILED} #{JOB}#{BUILD}$/, method: :failures
match /(?:failures|failed|f) #{JOB}#{BUILD} diff #{JOB}#{BUILD}$/, method: :diff match /(?:failures|failed|f) #{JOB}#{BUILD} diff #{JOB}#{BUILD}$/, method: :diff
match /Project (.+?) build #(\d+): (?:SUCCESS|FIXED) (?:.+?): (.*)$/, method: :green, :use_prefix => false match /Project (.+?) build #(\d+): (?:SUCCESS|FIXED) (?:.+?): (.*)$/, method: :green, :use_prefix => false
match /(?:job) (.*)$/, method: :update_branch


register_help 'failures|failed|f project', 'list failed tests (cukes and test units) from last test run' register_help 'failures|failed|f project', 'list failed tests (cukes and test units) from last test run'
register_help 'failures|failed|f project/test_number', 'list failed tests from specific test run' register_help 'failures|failed|f project/test_number', 'list failed tests from specific test run'
Expand Down Expand Up @@ -45,4 +47,12 @@ def green(m, project_name, build, url)
issues.comment(m, pull["number"], "Green: #{url}") if pull issues.comment(m, pull["number"], "Green: #{url}") if pull
end end
end end

def update_branch(m, new_branch)
config = Config.new(m.user.to_s)
config.update_branch(new_branch)
m.reply "Job updated"
rescue
m.reply "Error updating job"
end
end end
32 changes: 32 additions & 0 deletions plugins/hudson/config.rb
@@ -0,0 +1,32 @@
require 'open-uri'

class Hudson
class Config
BASE_URL = "http://localhost:8080"
CONFIG_URL = "/job/<project>/config.xml"

attr_reader :job

def initialize(job)
@job = job
end

def config_url
(BASE_URL + CONFIG_URL).gsub('<project>', job)
end

def config
@config ||= Nokogiri::XML(open(config_url))
end

def update_branch(branch_name)
config.xpath('/project/scm/branches/hudson.plugins.git.BranchSpec/name').each do |branch|
branch.content = branch_name
end

Curl::Easy.http_post(config_url, config.to_s) do |curl|
curl.headers['Content-Type'] = 'text/xml'
end
end
end
end
2 changes: 1 addition & 1 deletion plugins/hudson/fetcher.rb
@@ -1,6 +1,6 @@
class Hudson class Hudson
class Fetcher < Typhoeus::Request class Fetcher < Typhoeus::Request
BASE_URL = "http://localhost:8080/" BASE_URL = "http://localhost:8080"
JOB_URL = "/job/<project>/<test_run>/consoleText" JOB_URL = "/job/<project>/<test_run>/consoleText"


attr_reader :test_run attr_reader :test_run
Expand Down