Commit 776bca07 authored by Drew Blessing's avatar Drew Blessing
Browse files

Add Atlassian Bamboo service

parent adf66182f2ef
......@@ -3,6 +3,7 @@ v 7.5.0
- Add time zone configuration on gitlab.yml (Sullivan Senechal)
- Fix LDAP authentication for Git HTTP access
- Fix LDAP config lookup for provider 'ldap'
- Add Atlassian Bamboo CI service (Drew Blessing)
v 7.4.2
- Fix internal snippet exposing for unauthenticated users
......@@ -41,7 +41,8 @@ def service_params
:title, :token, :type, :active, :api_key, :subdomain,
:room, :recipients, :project_url, :webhook,
:user_key, :device, :priority, :sound
:user_key, :device, :priority, :sound, :bamboo_url, :username, :password,
......@@ -65,6 +65,7 @@ class Project < ActiveRecord::Base
has_one :gemnasium_service, dependent: :destroy
has_one :slack_service, dependent: :destroy
has_one :buildbox_service, dependent: :destroy
has_one :bamboo_service, dependent: :destroy
has_one :pushover_service, dependent: :destroy
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
has_one :forked_from_project, through: :forked_project_link
......@@ -313,7 +314,7 @@ def build_missing_services
def available_services_names
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack pushover buildbox)
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack pushover buildbox bamboo)
def gitlab_ci?
class BambooService < CiService
include HTTParty
prop_accessor :bamboo_url, :build_key, :username, :password
validates :bamboo_url, presence: true,
format: { with: URI::regexp }, if: :activated?
validates :build_key, presence: true, if: :activated?
validates :username, presence: true,
if: ->(service) { service.password? }, if: :activated?
validates :password, presence: true,
if: ->(service) { service.username? }, if: :activated?
attr_accessor :response
after_save :compose_service_hook, if: :activated?
def compose_service_hook
hook = service_hook || build_service_hook
def title
'Atlassian Bamboo CI'
def description
'A continuous integration and build server'
def help
'You must set up automatic revision labeling and a repository trigger in Bamboo.'
def to_param
def fields
{ type: 'text', name: 'bamboo_url',
placeholder: 'Bamboo root URL like' },
{ type: 'text', name: 'build_key',
placeholder: 'Bamboo build plan key like KEY' },
{ type: 'text', name: 'username',
placeholder: 'A user with API access, if applicable' },
{ type: 'password', name: 'password' },
def build_info(sha)
url = URI.parse("#{bamboo_url}/rest/api/latest/result?label=#{sha}")
if username.blank? && password.blank?
@response = HTTParty.get(parsed_url.to_s, verify: false)
get_url = "#{url}&os_authType=basic"
auth = {
username: username,
password: password,
@response = HTTParty.get(get_url, verify: false, basic_auth: auth)
def build_page(sha)
build_info(sha) if @response.nil? || !@response.code
if @response.code != 200 || @response['results']['results']['size'] == '0'
# If actual build link can't be determined, send user to build summary page.
# If actual build link is available, go to build result page.
result_key = @response['results']['results']['result']['planResultKey']['key']
def commit_status(sha)
build_info(sha) if @response.nil? || !@response.code
return :error unless @response.code == 200 || @response.code == 404
status = if @response.code == 404 || @response['results']['results']['size'] == '0'
if status.include?('Success')
elsif status.include?('Failed')
elsif status.include?('Pending')
def execute(_data)
# Bamboo requires a GET and does not take any data.
verify: false)
......@@ -28,7 +28,7 @@
- @service.fields.each do |field|
- name = field[:name]
- value = @service.send(name)
- value = @service.send(name) unless field[:type] == 'password'
- type = field[:type]
- placeholder = field[:placeholder]
- choices = field[:choices]
......@@ -45,6 +45,8 @@
= f.check_box name
- elsif type == 'select'
= name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" }
- elsif type == 'password'
= f.password_field name, class: 'form-control'
= f.submit 'Save', class: 'btn btn-save'
......@@ -5,6 +5,7 @@
- [API](api/ Explore how you can access GitLab via a simple and powerful API.
- [Markdown](markdown/ Learn what you can do with GitLab's advanced formatting system.
- [Permissions](permissions/ Learn what each role in a project (guest/reporter/developer/master/owner) can do.
- [Project Services](project_services/ Explore how project services can integrate a project with external services, such as for CI.
- [Public access](public_access/ Learn how you can allow public and internal access to a project.
- [SSH](ssh/ Setup your ssh keys and deploy keys for secure access to your projects.
- [Web hooks](web_hooks/ Let GitLab notify you when new code has been pushed to your project.
# Atlassian Bamboo CI Service
GitLab provides integration with Atlassian Bamboo for continuous integration.
When configured, pushes to a project will trigger a build in Bamboo automatically.
Merge requests will also display CI status showing whether the build is pending,
failed, or completed successfully. It also provides a link to the Bamboo build
page for more information.
Bamboo doesn't quite provide the same features as a traditional build system when
it comes to accepting webhooks and commit data. There are a few things that
need to be configured in a Bamboo build plan before GitLab can integrate.
## Setup
### Complete these steps in Bamboo:
1. Navigate to a Bamboo build plan and choose 'Configure plan' from the 'Actions'
1. Select the 'Triggers' tab.
1. Click 'Add trigger'.
1. Enter a description such as 'GitLab trigger'
1. Choose 'Repository triggers the build when changes are committed'
1. Check one or more repositories checkboxes
1. Enter the GitLab IP address in the 'Trigger IP addresses' box. This is a
whitelist of IP addresses that are allowed to trigger Bamboo builds.
1. Save the trigger.
1. In the left pane, select a build stage. If you have multiple build stages
you want to select the last stage that contains the git checkout task.
1. Select the 'Miscellaneous' tab.
1. Under 'Pattern Match Labelling' put '${bamboo.repository.revision.number}'
in the 'Labels' box.
1. Save
Bamboo is now ready to accept triggers from GitLab. Next, set up the Bamboo
service in GitLab
### Complete these steps in GitLab:
1. Navigate to the project you want to configure to trigger builds.
1. Select 'Settings' in the top navigation.
1. Select 'Services' in the left navigation.
1. Click 'Atlassian Bamboo CI'
1. Select the 'Active' checkbox.
1. Enter the base URL of your Bamboo server. ''
1. Enter the build key from your Bamboo build plan. Build keys are a short,
all capital letter, identifier that is unique. It will be something like PR-BLD
1. If necessary, enter username and password for a Bamboo user that has
access to trigger the build plan. Leave these fields blank if you do not require
1. Save or optionally click 'Test Settings'. Please note that 'Test Settings'
will actually trigger a build in Bamboo.
## Troubleshooting
If builds are not triggered, these are a couple of things to keep in mind.
1. Ensure you entered the right GitLab IP address in Bamboo under 'Trigger
IP addresses'.
1. Remember that GitLab only triggers builds on push events. A commit via the
web interface will not trigger CI currently.
# Project Services
__Project integrations with external services for continuous integration and more.__
## Services
- Assemblia
- [Atlassian Bamboo CI]( An Atlassian product for continous integration.
- Build box
- Campfire
- Emails on push
- Flowdock
- Gemnasium
- GitLab CI
- Hipchat
- PivotalTracker
- Pushover
- Slack
......@@ -54,3 +54,9 @@ Feature: Project Services
And I click email on push service link
And I fill email on push settings
Then I should see email on push service settings saved
Scenario: Activate Atlassian Bamboo CI service
When I visit project "Shop" services page
And I click Atlassian Bamboo CI service link
And I fill Atlassian Bamboo CI settings
Then I should see Atlassian Bamboo CI service settings saved
......@@ -14,6 +14,7 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
page.should have_content 'GitLab CI'
page.should have_content 'Assembla'
page.should have_content 'Pushover'
page.should have_content 'Atlassian Bamboo'
step 'I click gitlab-ci service link' do
......@@ -137,4 +138,23 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
find_field('Priority').find('option[selected]').value.should == '1'
find_field('Sound').find('option[selected]').value.should == 'bike'
step 'I click Atlassian Bamboo CI service link' do
click_link 'Atlassian Bamboo CI'
step 'I fill Atlassian Bamboo CI settings' do
check 'Active'
fill_in 'Bamboo url', with: ''
fill_in 'Build key', with: 'KEY'
fill_in 'Username', with: 'user'
fill_in 'Password', with: 'verySecret'
click_button 'Save'
step 'I should see Atlassian Bamboo CI service settings saved' do
find_field('Bamboo url').value.should == ''
find_field('Build key').value.should == 'KEY'
find_field('Username').value.should == 'user'
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