9

I am using TeamCity to build and deploy files onto a IIS website using Web Deploy 3.

I would like to add a step to call a url when done so that the custom cache can be refreshed when the deployment is finished.

Is there a way I can add a build step to call a url?

Thanks

Josh Buedel
  • 1,853
  • 16
  • 41
Base33
  • 3,167
  • 2
  • 27
  • 31

3 Answers3

8

I would solve this using a command line script that hits the url, and one of TeamCity's command line runners.

The question is tagged asp.net so I assume you're on Windows. Put this Get-WebFile script in a Powershell Build Runner. Then call Get-WebFile "http://yourwebapp.net/" at the bottom.

Josh Buedel
  • 1,853
  • 16
  • 41
  • That's what I ended up doing. It's actually a very good solution and allows me to do more than just call a url now. Just curious, how to I return an unsuccessful step if anything goes wrong? – Base33 Jan 15 '13 at 11:50
  • 2
    Third hit from the top: http://stackoverflow.com/search?q=how+to+fail+a+build+in+teamcity – Josh Buedel Jan 15 '13 at 23:16
  • How would I send credentials to a site using Integrated Windows authentication with this script? – Niklas Wulff Mar 04 '13 at 12:25
7

An even simpler method would be the same Powershell buildrunner step, but just use:

(New-Object System.Net.WebClient).DownloadString("http://yourwebapp.net");.

No dependencies on other scripts, just native Powershell. Anything wrong with that?

Robert Sirre
  • 672
  • 1
  • 8
  • 28
2

A newer, cleaner, just-as-simple method would be also using Powershell:

wget "http://yourwebapp.net"

wget is an alias for Invoke-WebRequest, supporting more options like settings the request timeout.

Full docs: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-6

NB: On older environments you may want to set -UseBasicParsing to prevent parsing errors.

Robert Sirre
  • 672
  • 1
  • 8
  • 28