를 들어,이 VSTS Rest API를 통해 현재 빌드의 커밋 메시지를받을 수있는 PowerShell 스크립트 작업을 추가 할 수 있습니다.
다음은 이것을 얻는 샘플 powershell 스크립트입니다.이 스크립트를 사용하려면 빌드 정의에서 "스크립트에서 OAuth 토큰에 액세스 허용"옵션을 사용해야합니다.
$collectionuri = $env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI
$buildid = $env:BUILD_BUILDID
$project = $env:SYSTEM_TEAMPROJECT
$token = $env:SYSTEM_ACCESSTOKEN
$basicAuth= ("{0}:{1}"-f "anys",$token)
$basicAuth=[System.Text.Encoding]::UTF8.GetBytes($basicAuth)
$basicAuth=[System.Convert]::ToBase64String($basicAuth)
$headers= @{Authorization=("Basic {0}"-f $basicAuth)}
$url= $collectionuri + $project + "/_apis/build/builds/" + $buildID + "/changes?api-version=2.0"
$getbuildchanges = Invoke-RestMethod -Uri $url -headers $headers -Method Get | select value
foreach ($commit in $getbuildchanges.value)
{
Write-Host $commit.id;
$commit.id | Out-File -filepath commitmessages.txt -Append;
Write-Host $commit.message;
$commit.message | Out-File -filepath commitmessages.txt -Append;
}
업데이트 : 다음 스크립트를 시도하십시오 : 여기 직물에서
$collectionuri = $env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI
$buildid = $env:BUILD_BUILDID
$project = $env:SYSTEM_TEAMPROJECT
$token = $env:SYSTEM_ACCESSTOKEN
$basicAuth= ("{0}:{1}"-f "anys",$token)
$basicAuth=[System.Text.Encoding]::UTF8.GetBytes($basicAuth)
$basicAuth=[System.Convert]::ToBase64String($basicAuth)
$headers= @{Authorization=("Basic {0}"-f $basicAuth)}
$url= $collectionuri + $project + "/_apis/build/builds/" + $buildID + "/changes?api-version=2.0"
$getbuildchanges = Invoke-RestMethod -Uri $url -headers $headers -Method Get;
if($getbuildchanges.count -ne 0)
{
foreach ($commit in $getbuildchanges.value)
{
Write-Host $commit.id;
$commit.id | Out-File -filepath release_notes.txt -Append;
Write-Host $commit.message;
$commit.message | Out-File -filepath release_notes.txt -Append;
}
}
else
{
$nocommitfound = "There is no commit related to current build.";
Write-Host $nocommitfound;
$nocommitfound | Out-File -filepath release_notes.txt -Append;
}
마이크. 빌드 흐름 중에 커밋을 .txt 파일에 저장할 수 있다면 Ant Beta 릴리스 명령을 통해 커밋을 업로드 할 수 있습니다. -DbetaDistributionReleaseNotesFilePath = release_notes.txt –
Thanks Mike. 사실 그건 내가 수동으로하는 한 부분입니다. 내가 필요한 것은 커밋에서 데이터를 자동으로 가져와 어떻게 든 파일을 만들고 업로드 할 수 있도록하는 것입니다. –
아, 알았어요! 미안하지만 나는 사물의 측면에 익숙하지 않다. –