Forked from nekdenis/gist:60a160a5a3503f0dbdd1a0a429aa8794
Created
March 25, 2019 14:43
-
-
Save korsander/4510b79c01894ad42c8d91093c520e75 to your computer and use it in GitHub Desktop.
TeamCity script git changes. Script that loads commit messages of last changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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