开发者

Setting up Bamboo SVN commit build trigger

Bamboo CI has a build in feature of having the subversion program trigger a build in bamboo when someone commits to the repository. I followed the instructions of what to put in the post commit hook but I am not sure what the 2 arguments are supposed to be for the postcommitbuildtrigger.sh file. Lets say the project name is TEST and the build name is TESTBUILD and the server url is http://localhost:8085. I wrote this in the post commit hook command line.

/<pathtopostcommit.sh> TEST TESTBUILD

Question

The post commit .sh file is on a windows machine. It could be because windows doesnt run .sh files but if thats so does anyone know how to set up this trigger on windows?

Also, I think this will trigger a build immediatly? Is is possible to trigger bamboo to run a poll instead so the build will obey the 开发者_高级运维quiet period?


Have to write your own scripts. Bamboo only distributes mac and linux scripts.


Ok I wrote my own. It's so much nicer than subversion poll time-outs. Tested on:

  • VisualSvn Server 2.7.2;
  • Windows Web Server 2008 R2.
  • PowerShell 2.0

BambooWebApiTrigger.bat

A batch file runner for PowerShell in C:\SvnHooks\:

@echo OFF
rem this file just makes spawning powershell from VisualSvn a tad easier...
rem
rem Args from VisualSvn Server are ignored. Pass Bamboo BUILD KEY as the first
rem parameter to this script.

Powershell.exe -executionpolicy remotesigned -File C:\SvnHooks\BambooWebApiTrigger.ps1 -key %1

BambooWebApiTrigger.ps1

A PowerShell script to run System.Net.WebClient, also in C:\SvnHooks\. Overwrite bamboo.yourdefaultdomain.com with your local Bamboo server:

# A Powershell script to trigger Bamboo to build a specific key
param (
    [string]$baseurl = "http://bamboo.radicalsystems.com.au:8085",
    [Parameter(Mandatory=$true)]
    [string]$key,
    [string]$tmp = $null
 )

$fullUrl = $baseurl + "/updateAndBuild.action?buildKey=" + $key
if (!$tmp) {
    $tmp = [io.path]::GetTempFileName()
}

echo "Pinging Bamboo API at '$fullUrl'"
$client = new-object System.Net.WebClient
$client.DownloadFile($fullUrl, $tmp)

# comment Remove-Item to see the results.  It is a HTML result with success message.
# echo "Results are in $tmp"
Remove-Item $tmp

Configure VisualSvn

Right click on project in VisualSvn Server Manager > Properties > Hooks > Post-commit hook (Edit).

Enter this line after any others:

C:\SvnHooks\BambooWebApiTrigger.bat BambooProjectKey

where BambooProjectKey is the key, found after your bamboo url when browsing the Build Plan (not the project). It usually has a hyphen in it: http://bamboo.yourdomain.com:8085/browse/FOO-BAR. In this case, FOO-BAR would be the key.

Configure Bamboo

Change your Bamboo trigger to Repository triggers the build when changes are committed

Options

You can overwrite the key from the VisualSvn post-commit hook dialog, as well as Bamboo base URL and temp file location from the batch file runner.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜