Artifact Paths does not use updated Environment Variable

We need to use a custom build format that team city does not support so i got around this by using the service messages in a powershell script to update the build number

I set my build number to


And the powershell script replaces the month and day with the date of the build. here is the script

$version = $Env:build_number $version = $version -replace "{DAY}",(Get-Date -format "dd") $version = $version -replace "{MONTH}",(Get-Date -format "MM") "##teamcity[message text='The build number will be $version' status='NORMAL']" "##teamcity[buildNumber '$version']"

Theis works and upades the buildnumber, i can see it in the parameter results. The problem though is i also need to package the result of a build into a zip that contains the build number but the zip end up as "1.{MONTH}.{DAY}" instead on the version that is set in the powershell script.
The artifact paths i am using is

.\bin\Release\*.* =>

I've aslo tried setting the env and sys variables in the powershell script

"##teamcity[env.BUILD_NUMBER '$version']" "##teamcity[setParameter name='' value='$version']" "##teamcity[setParameter name='' value='$version']"

and using the %build.number% and variables in the artifact paths. Nothing seems to work.

am i missing something??
Comment actions Permalink

Hello Ryan,

This is a know issue: please, watch/vote for it.

As a workaround, may I suggest you to publish your artifact using service message ? Here is the message, that will start publishing your artifact:

##teamcity[publishArtifacts '.\bin\Release\*.* => $']
Comment actions Permalink

Thanks for the work around. I ended up writing a console app to do the zipping and called it via a powershell script. then i just added any zip fles in a set location. Its not a elegant as this work around though becuase the code to ensure the error result of the console app bubbles up to team city is about 10 lines long.  


Please sign in to leave a comment.