Skip to content

Instantly share code, notes, and snippets.

@zsoi
Created November 4, 2016 13:13
Show Gist options
  • Save zsoi/0a299c77c1dea1ad32a199ff58c60c66 to your computer and use it in GitHub Desktop.
Save zsoi/0a299c77c1dea1ad32a199ff58c60c66 to your computer and use it in GitHub Desktop.
SVN post-commit hook for TC branch-agnostic build trigger
#!/bin/sh
# SVN post-commit hook that triggers a team city build with the modified branch
# and with the provided changeset
REPOS="$1"
REV="$2"
TXN_NAME="$3"
tcApi="https://teamcity/httpAuth/app/rest/buildQueue"
tcUser="builduser"
tcPassword="buildpassword"
buildId="buildid"
branchRegex="(trunk|branches/[a-zA-Z0-9_\-]+)/.*"
for f in `svnlook dirs-changed "$REPOS" -r $REV`
do
if [[ $f =~ $branchRegex ]]
then
branch="${BASH_REMATCH[1]}"
echo "<build><buildType id=\"$buildId\"/><properties><property name=\"system.branch\" value=\"$branch\"/><property name=\"build.vcs.number\" value=\"$REV\" /></properties></build>" | curl --basic --user "$tcUser:$tcPassword" --request POST "$tcApi" --header "Content-Type: application/xml" -k -d @-
exit
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment