Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

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

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
executes.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent ac8c1b9a1723
class BambooService < CiService
include HTTParty
prop_accessor :bamboo_url, :build_key, :username, :password
validates :bamboo_url, presence: true, url: true, if: :activated?
......@@ -112,8 +110,19 @@ def commit_status(sha, ref)
def execute(data)
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
self.class.get(url, verify: false)
if username.blank? && password.blank?
HTTParty.get(url, verify: false)
else
url << '&os_authType=basic'
auth = {
username: username,
password: password
}
HTTParty.get(url, verify: false, basic_auth: auth)
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