How to configure source code management triggers for Subversion

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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:

  1. Anonymous enabled
  2. Anonymous disabled, providing user's authentication

Causing error on triggering build:

  1. Anonymous disabled and no user's authentication is provided

1. Anonymous enabled

When running using the following configuration Bamboo will run builds:

postCommitBuildTrigger.py
#!/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
#!/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
#!/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

# 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]
Last modified on Nov 2, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.