Configuring Git Repository to trigger the build in a Windows environment
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article is a guideline to configure a Git repository to trigger a Bamboo build in Windows. The steps are mainly covered in: Repository triggers the build when changes are committed, but due to different default settings and commands in a Windows environment, there are some differences.
The overall process is: a commit to the repository causes a post-commit message to be sent to Bamboo. Bamboo then responds by checking the repository for un-built changes. If changes are found, Bamboo triggers a build.
Solution
Configuring the repository to trigger the build when changes are committed requires two steps:
Configuring your source repository
Copy the scripts to your repository. If you are using the Bamboo distribution, the scripts are located in the
/scripts
folder of your Bamboo Installation Directory. If you are using Bamboo EAR-WAR distribution, you can find them in the/repositoryScripts
folder.Edit the Git respository's
.git/hooks/post-commit
trigger file with something like: /pathto/postCommitBuildTrigger.py http://bambooserver MYTESTPROJECT-MYTESTPLAN. In "MYTESTPROJECT-MYTESTPLAN", MYTESTPROJECT is the project name in Bamboo and MYTESTPLAN is the plan name. Make sure that Python 2.X is installed. Also, since the hook will look for python under the default path "/usr/bin/python" add the path to the python executable in the beginning. Also, use use double quotation marks for local paths.Example:
In this example "C:\Users\ssetayeshfar\hello" is the path to my local git repository. The "postCommitBuildTrigger.py" from under svn-triggers should be used.
1
"C:\Python27\python.exe" "C:\Users\ssetayeshfar\hello\svn-triggers\postCommitBuildTrigger.py" http://localhost:8085 MYTESTPROJECT-MYTESTPLAN
Ensure that the user which Bamboo is running as has appropriate file permissions to execute the scripts, i.e. the scripts should be executable by non-root user(s).
Configuring Bamboo to respond to post-commit messages
Before you begin:
Triggering a build when there is no repository update — Bamboo will ignore build triggering requests if there are no changes committed to the repository branch, which is configured for the particular Bamboo plan.
To configure Bamboo to trigger a build:
Click Dashboard and then the All Plans tab.
Locate the plan in the list and click the edit icon to display the plan's configuration pages.
Click the Triggers tab, then click either an existing trigger or Add Trigger.
Optionally, enter a trigger description.
Choose Trigger type > Repository triggers the build when changes are committed.
Bamboo displays the available repositories for the plan, as previously configured on the Source Repositories tab. Choose the repositories that this trigger should apply to.
Only enter an IP address in Trigger IP Addresses if you want Bamboo to trigger on post-commit messages from other than the primary IP address for the repository.
Was this helpful?