How to configure source code management triggers for Subversion
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
The following expounds on Configuring source code management triggers for Subversion, explaining how the authentication is done based on plan permissions. The following permissions are explained:
Anonymous enabled
Anonymous disabled, providing user's authentication
Causing error on triggering build:
Anonymous disabled and no user's authentication is provided
Solution
1. Anonymous enabled
When running using the following configuration Bamboo will run builds:

postCommitBuildTrigger.py
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/python
#
# ./postCommitBuildTrigger.py http://bamoo.atlassian.com/bamboo/ myBuildName
import sys
import urllib;
baseUrl = sys.argv[1]
buildKey = sys.argv[2]
remoteCall = baseUrl + "/api/rest/updateAndBuild.action?buildKey=" + buildKey
fileHandle = urllib.urlopen(remoteCall)
fileHandle.close()
2. Anonymous disabled, providing user's authentication
If you want to leave "Anonymous users" disabled, you must edit the "postCommitBuildTrigger.py" to provide a user's Bamboo credentials.

The following is an example on how to accomplish this written in Python. Remember, the "postCommitBuildTrigger.py" is a Python script, so you can edit it to reflect your specific requirements, e.g. trigger after X commits, trigger only when a commit message has a particular word, etc.
postCommitBuildTrigger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/python
#
# ./postCommitBuildTrigger.py http://bamoo.atlassian.com/bamboo/ myBuildName
import sys
import urllib2
import base64
baseUrl = sys.argv[1]
buildKey = sys.argv[2]
# the user provided MUST have access to the Plan
username = 'admin'
password = 'admin'
remoteCall = baseUrl + "/api/rest/updateAndBuild.action?buildKey=" + buildKey
request = urllib2.Request(remoteCall)
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
result = urllib2.urlopen(request)
result.close()
1. Anonymous disabled and no user's authentication is provided
Given the following configuration:

postCommitBuildTrigger.py
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/python
#
# ./postCommitBuildTrigger.py http://bamoo.atlassian.com/bamboo/ myBuildName
import sys
import urllib;
baseUrl = sys.argv[1]
buildKey = sys.argv[2]
remoteCall = baseUrl + "/api/rest/updateAndBuild.action?buildKey=" + buildKey
fileHandle = urllib.urlopen(remoteCall)
fileHandle.close()
The following appears in the <bamboo-home>/logs/atlasian-bamboo.log
1
2
3
4
5
# when running 'postCommitBuildTrigger.py', Bamboo does not run builds
# Authorization failed: org.acegisecurity.AccessDeniedException: Access is denied
#
2015-12-24 17:19:21,753 INFO [http-bio-8085-exec-2] [AccessLogFilter] 127.0.0.1 GET http://localhost:8085/api/rest/updateAndBuild.action?buildKey=PROJ-PLAN 56080kb
2015-12-24 17:19:21,779 WARN [http-bio-8085-exec-2] [AuthorizationLoggerListener] Authorization failed: org.acegisecurity.AccessDeniedException: Access is denied; authenticated principal: org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken@9055e4a6: Username: anonymousUser; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS; secure object: ReflectiveMethodInvocation: public abstract java.util.List com.atlassian.bamboo.plan.cache.CachedPlanManager.getBranchesForChain(com.atlassian.bamboo.plan.PlanIdentifier); target is of class [com.atlassian.bamboo.plan.cache.CachedPlanManagerImpl]; configuration attributes: [ACL_BUILD_READ]
Was this helpful?