Permalink
Browse files

Merge remote-tracking branch 'origin/master' into hipchat

Conflicts:
	janky.gemspec
	lib/janky.rb
  • Loading branch information...
2 parents f4f6a2e + 0340b87 commit 230610860e39c1b843c38c5bed438ca43db5fd18 @sr sr committed Jan 3, 2012
Showing with 43 additions and 11 deletions.
  1. +4 −3 README.md
  2. +1 −1 lib/janky.rb
  3. +1 −1 lib/janky/builder/receiver.rb
  4. +23 −0 lib/janky/exception.rb
  5. +1 −1 lib/janky/hubot.rb
  6. +12 −4 lib/janky/job_creator.rb
  7. +1 −1 lib/janky/views/index.rb
View
@@ -117,7 +117,8 @@ Required settings:
* `JANKY_BASE_URL`: The application URL with a trailing slash. Example:
`http://mf-doom-42.heroku.com/`.
* `JANKY_BUILDER_DEFAULT`: The Jenkins server URL with a trailing slash.
- Example: `http://jenkins.example.com/`.
+ Example: `http://jenkins.example.com/`. For basic auth, include the
+ credentials in the URL: `http://user:pass@jenkins.example.com/`.
* `JANKY_CONFIG_DIR`: Directory where build config templates are stored.
Typically set to `/app/config` on Heroku.
* `JANKY_HUBOT_USER`: Login used to protect the Hubot API.
@@ -165,7 +166,7 @@ a few extra settings:
Install the [janky script](http://git.io/hubot-janky) in your Hubot
then set the `HUBOT_JANKY_URL` environment variable. Example:
`http://user:secret@janky.example.com/_hubot/`, with user and password
-replaced by `JANKY_HUBOT_USER` and `JANKY_HUBOT_PASSWORD` repectively.
+replaced by `JANKY_HUBOT_USER` and `JANKY_HUBOT_PASSWORD` respectively.
### Custom Build Configuration
@@ -226,5 +227,5 @@ send a Pull Request.
Copying
-------
-Copyright © 2011, GitHub, Inc. See the `COPYING` file for license
+Copyright © 2011-2012, GitHub, Inc. See the `COPYING` file for license
rights and limitations (MIT).
View
@@ -137,7 +137,7 @@ def self.setup(settings)
:password => settings["JANKY_HUBOT_PASSWORD"]
)
- Janky::Exception.setup(Janky::Exception::Mock)
+ Janky::Exception.setup(Janky::Exception::Logger.new($stderr))
chat_name = settings["JANKY_CHAT"] || "campfire"
chat_settings = {}
@@ -10,7 +10,7 @@ def self.call(env)
elsif payload.completed?
Build.complete(payload.id, payload.green?)
else
- return Rack::Response.new("Invalid", 402).finish
+ return Rack::Response.new("Bad Request", 400).finish
end
Rack::Response.new("OK", 201).finish
@@ -48,6 +48,29 @@ def call(env)
end
end
+ class Logger
+ def initialize(stream)
+ @stream = stream
+ @context = {}
+ end
+
+ def reset!
+ @context = {}
+ end
+
+ def report(e, context={})
+ @stream.puts "ERROR: #{e.class} - #{e.message}\n"
+ @context.each do |k, v|
+ @stream.puts "%12s %4s\n" % [k, v]
+ end
+ @stream.puts "\n#{e.backtrace.join("\n")}"
+ end
+
+ def push(context)
+ @context.update(context)
+ end
+ end
+
class Mock
def self.push(context)
end
View
@@ -4,7 +4,7 @@ module Janky
# builds.
#
# The client side implementation is at
- # <https://github.com/github/hubot/blob/master/scripts/ci.js>
+ # <https://github.com/github/hubot-scripts/blob/master/src/scripts/janky.coffee>
class Hubot < Sinatra::Base
register Helpers
@@ -71,9 +71,13 @@ def self.exists?(server_url, name)
uri = server_url
user = uri.user
pass = uri.password
+ path = uri.path
http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl=true if (uri.scheme.casecmp("https") == 0)
- get = Net::HTTP::Get.new("/job/#{name}/")
+ if uri.scheme == "https"
+ http.use_ssl = true
+ end
+
+ get = Net::HTTP::Get.new("#{path}/job/#{name}/")
get.basic_auth(user, pass) if user && pass
response = http.request(get)
@@ -92,9 +96,13 @@ def self.run(server_url, name, config)
uri = server_url
user = uri.user
pass = uri.password
+ path = uri.path
http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl=true if (uri.scheme.casecmp("https") == 0)
- post = Net::HTTP::Post.new("/createItem?name=#{name}")
+ if uri.scheme == "https"
+ http.use_ssl = true
+ end
+
+ post = Net::HTTP::Post.new("#{path}/createItem?name=#{name}")
post.basic_auth(user, pass) if user && pass
post["Content-Type"] = "application/xml"
post.body = config
@@ -25,7 +25,7 @@ def css_status_for(build)
def last_built_text_for(build)
if build.building?
- "Building since <span class='relatize'>#{build.started_at}</span>…"
+ "Build started <span class='relatize'>#{build.started_at}</span>…"
elsif build.completed?
"Built in <span>#{build.duration}</span> seconds"
end

0 comments on commit 2306108

Please sign in to comment.