Bamboo local network deploy into IIS

I'm new to Bamboo and have Stash and JIRA already in my stack. I'm got a task setup for get the latest files from Stash and build them with VS. The output is deployed into a directory called 'target'. I am having trouble actually deploying this software. My IIS is a server inside my network. I've created a map but the download artifact deploy task is only relative. My directory looks like: z:\inetpub\wwroot\mywebapp This seems like a very simple task but i can't seem to figure out the right approach.

1 answer

The artifact download is intended to copy the artifact made from a previous job into a local working copy so that part is correct. An IIS application need not only the files but to be in IIS Manager "Convert to application" the first time to set it up correctly and then it will be in the Default App Pool unless moved. This can also be done with scripts as shown below.

IIS can hold onto files for requests and say they're deleted but not actually delete them, this cause an issue when trying to copy over new files; we've seen quite a few times the entire directory be empty after a simple copy of new files. To deploy without these issues, you'll need to stop the AppPool first. To keep all of the AppPool configurations in sync across sites and avoid manual steps; we deleted the Application and AppPool and make new ones each time. Here is an example powershell script we use, as is it needs to be run from the server you're installing to be you can change than or invoke it on that machine.

Import-Module WebAdministration
if (Test-Path "IIS:\AppPools\$appName")
{	Remove-WebAppPool $appName	}
if (Get-WebApplication -Name "services/$appName")
{	Remove-WebApplication -Name "services/$appName" -Site "Default Web Site"	}
InstallWebService $appName
$appPool = New-WebAppPool $appName
$appPool.managedRuntimeVersion = "v4.0"
$appPool | Set-Item
New-WebApplication -Name "services/$appName" -Site "Default Web Site" -PhysicalPath "C:\inetpub\wwwroot\services\$appName" -ApplicationPool $appName

"InstallWebService" is a custom function of ours that simply copies the files over (we use robocopy), for that piece you'll need to setup a shared directory or use the default ones with admin rights \\servername\z$\inetpub\wwroot\mywebapp and just copy your build results, probably your artifact, to that location.

You can use whatever AppPool or AppPool configuration you want, we went ahead and are making a separate AppPool for each application which may not work for your situation. Removing the application from IIS instead of just the files underneath it will stop the application and allow you properly copy the new files over so you might choose to skip the AppPool delete parts but I'd still keep a check and creation for new deployments.

For what it's worth it is possible to recycle the AppPools via a cscript command from bamboo, but it forks off and frequently fails to return a result causing the build to hang. I finally gave up and resorted to running a script manually for the recycle step on a deploy.

Also you'll get a better result with robocopy than xcopy. We had issues with xcopy hitting a locked file and skipping it or terminating on a lock and producing unreliable deployments. Robocopy allows you to use retries and can log all files copied so you know what you're getting is correct and complete. The syntax for robocopy is completely different than xcopy. Officially xcopy is deprecated in favor of robocopy.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,786 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you