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: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
f34af6b83c
commit
84b07f7054
|
@ -1,6 +1,4 @@
|
|||
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 @@ class BambooService < CiService
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue