Created
December 28, 2016 20:33
-
-
Save TomerAdmon/88aa54703bee984d2fe0e2f610359d66 to your computer and use it in GitHub Desktop.
Download artifacts for the last successful build from TeamCIty
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
$FOLDER_NAME = "DownlodedFiles" | |
$TEAM_CITY = 'http://TC' | |
$BUILD_TYPE_ID = "Trunk_Ci_FastCi_Build" | |
$FILES_TO_DOWNLOAD = ".zip" | |
$folderName = (".\" + $FOLDER_NAME) | |
If (Test-Path $folderName){ | |
Remove-Item $folderName | |
} | |
New-Item -ItemType Directory -Force -Path $folderName | |
#Get The Last Build Id | |
$GetLastBuild = $TEAM_CITY + | |
'/guestAuth/app/rest/buildTypes/id:' + $BUILD_TYPE_ID + '/builds/running:false,status:success' | |
#Get The Artifacts list | |
$xmlout = [xml](Invoke-WebRequest $GetLastBuild).Content | |
$artifactsPath = $xmlout.SelectNodes('//artifacts').href | |
$getArtifactsChilds = $TEAM_CITY + $artifactsPath | |
#Download File | |
$xmlout = [xml](Invoke-WebRequest $getArtifactsChilds).Content | |
$FileToDownload = ($xmlout.SelectNodes('//content') | Where-Object -Property href -match .zip).href | |
$fileName = ($xmlout.SelectNodes('//file') | Where-Object -Property href -match $FILES_TO_DOWNLOAD).name | |
$FileToDownload = $TEAM_CITY + $FileToDownload | |
Invoke-WebRequest $FileToDownload -OutFile "$folderName\$fileName" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment