GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Unverified Commit 46f3cd7c authored by Benjamin Schmid's avatar Benjamin Schmid Committed by Rémy Coutable

Fix broken URI joining for `bamboo_url` with suffixes

If one had configured a `bamboo_url` like http://foo.bar/bamboo in the
previous implementation the plugin directed it's request i.e. to
http://foo.bar/rest/... instead of http://foo.bar/bamboo/rest/...

`URI.join` only works correctly, if the prefix URL has
  - at least one or more  trailing '/'
  - the appended parts are _not_ prefixed with '/'

The current implementation should work with all sorts of Bamboo base URLs.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 84b07f70
......@@ -38,6 +38,7 @@ v 8.9.0 (unreleased)
- Add option to project to only allow merge requests to be merged if the build succeeds (Rui Santos)
- Fix issues filter when ordering by milestone
- Added artifacts:when to .gitlab-ci.yml - this requires GitLab Runner 1.3
- Bamboo Service: Fix missing credentials & URL handling when base URL contains a path (Benjamin Schmid)
- Todos will display target state if issuable target is 'Closed' or 'Merged'
- Fix bug when sorting issues by milestone due date and filtering by two or more labels
- Add support for using Yubikeys (U2F) for two-factor authentication
......
......@@ -59,7 +59,7 @@ def supported_events
end
def build_info(sha)
url = URI.join(bamboo_url, "/rest/api/latest/result?label=#{sha}").to_s
url = URI.join("#{bamboo_url}/", "rest/api/latest/result?label=#{sha}").to_s
if username.blank? && password.blank?
@response = HTTParty.get(url, verify: false)
......@@ -78,11 +78,11 @@ def build_page(sha, ref)
if @response.code != 200 || @response['results']['results']['size'] == '0'
# If actual build link can't be determined, send user to build summary page.
URI.join(bamboo_url, "/browse/#{build_key}").to_s
URI.join("#{bamboo_url}/", "browse/#{build_key}").to_s
else
# If actual build link is available, go to build result page.
result_key = @response['results']['results']['result']['planResultKey']['key']
URI.join(bamboo_url, "/browse/#{result_key}").to_s
URI.join("#{bamboo_url}/", "browse/#{result_key}").to_s
end
end
......@@ -111,7 +111,7 @@ def execute(data)
return unless supported_events.include?(data[:object_kind])
# Bamboo requires a GET and does take authentification
url = URI.join(bamboo_url, "/updateAndBuild.action?buildKey=#{build_key}").to_s
url = URI.join("#{bamboo_url}/", "updateAndBuild.action?buildKey=#{build_key}").to_s
if username.blank? && password.blank?
HTTParty.get(url, verify: false)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment