Skip to content

Instantly share code, notes, and snippets.

@nekdenis
Created July 19, 2016 14:57
Show Gist options
  • Save nekdenis/60a160a5a3503f0dbdd1a0a429aa8794 to your computer and use it in GitHub Desktop.
Save nekdenis/60a160a5a3503f0dbdd1a0a429aa8794 to your computer and use it in GitHub Desktop.
TeamCity script git changes. Script that loads commit messages of last changes
#!/bin/bash
# Where the changelog file will be created
outputFile='%system.teamcity.build.tempDir%/releasenotesfile_%teamcity.build.id%.txt'
# the url of teamcity server
teamcityUrl='%teamcity.serverUrl%'
# username to access Teamcity REST API
username='%system.teamcity.auth.userId%'
# password to access Teamcity REST API
password='%system.teamcity.auth.password%'
# Build id for the release notes
buildTypeId=%system.teamcity.buildType.id%
request="$teamcityUrl/app/rest/buildTypes/id:$buildTypeId/builds/running:true"
echo request = $request
curl -o lastBuild.tmp $request --user $username:$password
cat lastBuild.tmp
last_commit=`xpath lastBuild.tmp '/build/revisions/revision/@version'| awk -F"\"" '{print $2}'`
request="$teamcityUrl/app/rest/buildTypes/id:$buildTypeId/builds/start:0"
echo request = $request
curl -o lastBuild1.tmp $request --user $username:$password
cat lastBuild1.tmp
previous_commit=`xpath lastBuild1.tmp '/build/revisions/revision/@version'| awk -F"\"" '{print $2}'`
echo "git log --pretty=format:"- %%s" $last_commit..$previous_commit"
git log --pretty=format:"- %%s" $previous_commit..$last_commit > $outputFile
cat $outputFile
echo "Changelog saved to $outputFile:"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment