Skip to content
Browse files

Merge pull request #89 from github/build-url

Expose build url to notifiers
  • Loading branch information...
2 parents 3f7330a + cb9f208 commit 1b2453d523541f014f21a9e49b48107192ac9c70 @sr sr committed Jul 4, 2012
Showing with 29 additions and 3 deletions.
  1. +4 −3 lib/janky.rb
  2. +17 −0 lib/janky/build.rb
  3. +8 −0 test/janky_test.rb
View
7 lib/janky.rb
@@ -97,6 +97,7 @@ def self.setup(settings)
settings["JANKY_BASE_URL"] = settings["JANKY_BASE_URL"] + "/"
end
base_url = URI(settings["JANKY_BASE_URL"]).to_s
+ Build.base_url = base_url
connection = {
:adapter => adapter,
@@ -212,10 +213,10 @@ def self.required_settings
JANKY_HUBOT_USER JANKY_HUBOT_PASSWORD]
end
- # Directory where Jenkins job configuration templates are located.
- #
- # Returns the directory as a Pathname.
class << self
+ # Directory where Jenkins job configuration templates are located.
+ #
+ # Returns the directory as a Pathname.
attr_accessor :jobs_config_dir
end
View
17 lib/janky/build.rb
@@ -192,6 +192,19 @@ def room_name
end
end
+ class << self
+ # The full URL of the web app as a String, including the protocol.
+ attr_accessor :base_url
+ end
+
+ # URL of this build's web page, served by Janky::App.
+ #
+ # Returns the URL as a String.
+ def web_url
+ return if new_record?
+ self.class.base_url + "#{id}/output"
+ end
+
def repo_id
repository.id
end
@@ -204,6 +217,10 @@ def repo_name
repository.name
end
+ def repo_nwo
+ repository.nwo
+ end
+
def repository
branch.repository
end
View
8 test/janky_test.rb
@@ -327,4 +327,12 @@ def setup
assert_equal "github", repo.github_owner
assert_equal "pygments.rb", repo.github_name
end
+
+ test "build janky url" do
+ gh_post_receive("github")
+ Janky::Builder.start!
+ Janky::Builder.complete!
+
+ assert_equal "http://localhost:9393/1/output", Janky::Build.last.web_url
+ end
end

0 comments on commit 1b2453d

Please sign in to comment.
Something went wrong with that request. Please try again.