Passing An Azure Staging Slot URI To A Test Runner In Visual Studio Team Services Release Management

July 12 2016

I wanted to run our coded ui tests using Selenium against the staging uri during our continuous integration workflow of our cloud service web role. But the problem arose that I didn’t know the dynamically generated URI that gets created by Azure when deploying to the staging slot.

I chatted with DevOps guru Thiago Almeida about this and he had the following suggestion:

Add a Powershell script between the publish step and the test step.  Here’s what the Powershell looked like:

$deployment = Get-AzureDeployment -ServiceName service_name -Slot Staging

if ($deployment -eq $null)

{

   write-host "No deployment is detected. "

   //Throw an exception for the build to fail here…

}

else

{

   $deploymentUrl = $deployment.Url

   # As explained here this next line creates a new variable with the value that other tasks can use https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md

   Write-Host ("##vso[task.setvariable variable=StagingWebsiteURL;]$deploymentUrl")

}

 

To use this, you’ll need to change the service_name to your Azure service name.

Then, on the Test Assemblies task’s “Override TestRun Parameters” value, update it to this to set the base URL to be the value of the variable set in the PowerShell task above:

webAppUrl=$(StagingWebsiteURL)

 

Nice! It totally worked! Tip of the hat to Thiago Almeida for suggesting this!

Using GitFlow With Powershell

October 11 2013

We are using GitFlow on our team but I don't want to use CygWin; I'm not a Bash kind of guy. There are instructions for installing GitFlow for use with the Git PowerShell window here.  However, there are some gotchas. First, you'll need getopt.exe and libintl3.dll. To make your life easier, I've attached them as a zip file to this post.

Second, note that you have to follow their instructions exactly when cloning the gitflow repo. You have to run the command

git clone --recursive git://github.com/nvie/gitflow.git

If you don't and just run a git clone command without specifying recursive, you may get the following error when you attempt to run the msysgit-install script:

File not found - shflags
0 File(s) copied
Some unexpected errors happened. Sorry, you'll have to fix them by yourself. [Y]?Y

Hopefully, that might help someone out there...

GitFlowFiles.zip (59.05 kb)