What are my PowerShell options for determining a path that changes with every build (TeamCity)? -


i'm on project uses teamcity builds.

i have vm, , have written powershell script backs few files, opens zip artifact manually download teamcity, , copies vm.

i'd enhance script having retrieve zip artifact (which has same name).

the problem download path contains build number changing. aside requesting download path zip artifact, don't care is.

an example artifact path might be:

http://{server}/repository/download/{project}/{build_number}:id/{project}.zip

there "last successful build" page in teamcity might able obtain build number from.

what think best way approach issue is?

i'm new teamcity, answer "teamcity - don't need powershell script." direction in regard helpful.

at moment, powershell script trick , takes 30 seconds run (which faster peers of file copying manually). i'd happy automating zip download can "fire , forget" script , end updated vm.

seems smallest knowledge gap fill , retrieving changing path info @ run-time powershell seems pretty decent skill have.

i might use c# within ps collect info, hoping more ps way it.

thanks in advance thoughts , advice!

update: turns out other teams had been using octopus deploy (https://octopus.com/) sort of thing i'm using - though seems more cumbersome ps solution overall since involves logging octopus server , going through few steps kick off new build manually @ point.

i'm waiting tc administrator provide webhook or notify octopus when new build available. once have that, octopus admin says should able deployments happen automagically.

on bright side, have build process integrated microsoft teams via webhook plugin available octopus. also, developer of octopus looking @ making microsoft teams connector simplify this. it's nice notification new build available right in team chat.

you can try artefact url:

http://<serverurl>/repository/downloadall/<buildid>/.lastsuccessful 

where buildid unique identifier of build configuration.

my implementation of question is, in powershell:

# # getartefact.ps1 # param(     [parameter(mandatory=$false)][string]$teamcityserver="",     [parameter(mandatory=$false)][string]$buildconfigurationid="",     [parameter(mandatory=$false)][string]$localpathtosave="" ) begin {     $username = "guest";     $password = "guest";      function execute-httpgetcommand() {         param(             [string] $target = $null         )         $request = [system.net.webrequest]::create($target)         $request.preauthenticate = $true         $request.method = "get"                   $request.headers.add("authorization", "basic");         $request.accept = "*"         $request.credentials = new-object    system.net.networkcredential($username, $password)         $response = $request.getresponse()          $sr = [io.streamreader]($response.getresponsestream())         $file = $sr.readtoend()         return $file;     }        execute-httpgetcommand http://$teamcityserver/repository/downloadall/$buildconfigurationid/.lastsuccessful | out-file $localpathtosave  } 

and call appropriate parameters.

edit: note current credential used here guest account. should check if guest account has permissions this, or specify appropriate account.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -