Unverified Commit 84b07f70 authored by Benjamin Schmid's avatar Benjamin Schmid Committed by Rémy Coutable

Honor credentials on calling Bamboo CI trigger

This improves the Bamboo Service and provides a fix for situations,
where the build trigger won't work, because Bamboo is requiring
authentication also for the trigger GET.

The change now does provide additional HTTP Basic Auth parameters
if user credentials were provided and appends an request parameter
indicating the HTTP Basic Authentication should be used.
This aligns interaction with Bamboo with the other calls this service
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent f34af6b8
class BambooService < CiService class BambooService < CiService
include HTTParty
prop_accessor :bamboo_url, :build_key, :username, :password prop_accessor :bamboo_url, :build_key, :username, :password
validates :bamboo_url, presence: true, url: true, if: :activated? validates :bamboo_url, presence: true, url: true, if: :activated?
...@@ -112,8 +110,19 @@ def commit_status(sha, ref) ...@@ -112,8 +110,19 @@ def commit_status(sha, ref)
def execute(data) def execute(data)
return unless supported_events.include?(data[:object_kind]) return unless supported_events.include?(data[:object_kind])
# Bamboo requires a GET and does not take any data. # 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
self.class.get(url, verify: false)
if username.blank? && password.blank?
HTTParty.get(url, verify: false)
url << '&os_authType=basic'
auth = {
username: username,
password: password
HTTParty.get(url, verify: false, basic_auth: auth)
end end
end end
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