doc/user/project/integrations/bamboo.md
{{< details >}}
{{< /details >}}
You can automatically trigger builds in Atlassian Bamboo when you push changes to your project in GitLab.
Bamboo doesn't provide the same features as a traditional build system when accepting webhooks and commit data. You must configure a Bamboo build plan before you configure the integration in GitLab.
GitLab trigger.${bamboo.repository.revision.number}
in Labels.Bamboo is ready to accept triggers from GitLab. Next, set up the Bamboo integration in GitLab.
https://bamboo.example.com.A build key is a unique identifier typically made up from the project key and
plan key.
Build keys are short, all uppercase, and separated with a dash (-),
for example PROJ-PLAN.
The build key is included in the browser URL when you view a plan in
Bamboo. For example, https://bamboo.example.com/browse/PROJ-PLAN.
You can use a script that uses the commit status API and Bamboo build variables to:
target_url.For example:
Create a personal access token with the scope set to api.
Save the token as a $GITLAB_TOKEN variable in Bamboo.
Add the following script as a final task to the Bamboo plan's jobs:
#!/bin/bash
# Script to update CI status on GitLab.
# Add this script as final inline script task in a Bamboo job.
#
# General documentation: https://docs.gitlab.com/user/project/integrations/bamboo/
# Fix inspired from https://gitlab.com/gitlab-org/gitlab/-/issues/34744
# Stop at first error
set -e
# Access token. Set this as a CI variable in Bamboo.
#GITLAB_TOKEN=
# Status
cistatus="failed"
if [ "${bamboo_buildFailed}" = "false" ]; then
cistatus="success"
fi
repo_url="${bamboo_planRepository_repositoryUrl}"
# Check if SSH or HTTPS is in use
protocol=${repo_url::4}
if [ "$protocol" == "git@" ]; then
repo=${repo_url:${#protocol}};
gitlab_url=${repo%%:*};
else
protocol="https://"
repo=${repo_url:${#protocol}};
gitlab_url=${repo%%/*};
fi
start=$((${#gitlab_url} + 1)) # +1 for the / (https) or : (ssh)
end=$((${#repo} - $start -4)) # -4 for the .git
repo=${repo:$start:$end}
repo=$(echo "$repo" | sed "s/\//%2F/g")
# Send request
url="https://${gitlab_url}/api/v4/projects/${repo}/statuses/${bamboo_planRepository_revision}?state=${cistatus}&target_url=${bamboo_buildResultsUrl}"
echo "Sending request to $url"
curl --fail --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$url"
If builds are not triggered, ensure you entered the right GitLab IP address in Bamboo under Trigger IP addresses. Also, check the integration webhook logs for request failures.
Advanced Atlassian Bamboo features are not compatible with GitLab. These features include, but are not limited to, the ability to watch the build logs from the GitLab UI.