• Rémy Coutable's avatar
    Merge branch 'bentolor/gitlab-ce-fix/bamboo-service-trigger-auth' into 'master' · 0068ba8d
    Rémy Coutable authored
    Bamboo & TeamCity Services: Fix missing credentials & URL handling
    
    _Note: Originally opened at !4367 by @bentolor_
    
    I've also fixed the URL handling for TeamCity which is very similar to Bamboo implementation-wise.
    
    -----
    
    *Note:* This is a port from my [original pull request on GitHub](https://github.com/gitlabhq/gitlabhq/pull/9428)
    
    ## What does this MR do?
    This improves the Bamboo Service and provides two fixes:
    
    1. One for the situation, where the build trigger won't work because Bamboo is requiring authentication credentials for the trigger GET: 8f25aca307b49ee006172b8c2985a878800aa6b6
    2. One which fixes the way how the configured Bamboo base URL is assembled to the final REST URL. fe9eb30d7ebe4a83eefea7e06f8b69b135dad15d
    
    ### Regarding credentials
    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.
    
    ### Regarding URL handling
    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/...
    
    
    ## Are there points in the code the reviewer needs to double check?
    The second issues was probably an unwanted side effect of how Ruby's `URI.join` is working. It will only work correctly, if 
    - ... the prefix URL has at least one or more  trailing `/`
    - .. the appendix parts are _not_ prefixed with `/`
    
    I need try & figure it out using the rather lacking, official stdlib documentation and playing around in `irb`. As I'm an absolute Ruby novice I'm unable to add/provide new tests.
    
    ## Why was this MR needed?
    Because Gitlab does not work in our Bamboo-Environment at all: Neither it is able to trigger Bamboo runs nor does the Merge status check work. This MR at least fixes the trigger issues.
    
    ## What are the relevant issue numbers?
    This MR originates from my [original pull request on GitHub](https://github.com/gitlabhq/gitlabhq/pull/9428).
    Sadly the issue, that the merge status is still not working correctly for branches will still not work. But at least the trigger works. 
    
    There happened to be very much discussion about the branch status issue in #1355 and  #2562 though that one is lost as the author retracted his branch. 
    
    See merge request !4408
    0068ba8d
To find the state of this project's repository at the time of any of these versions, check out the tags.