Continuous Integration Lab for MSIT


Tuesday we are doing a DevOps Lab for MSIT and wanted to streamline/tune the walk through for this internal audience.

In this lab, you will learn about four of the five major DevOps Enablers:

  1. Continuous Integration
  2. Continuous Deployment
  3. Continuous Testing
  4. Application Monitoring

 

Step 1. Getting started with the standard steps for getting started with GIT

image

Note: The sample we will be using can also be found at: https://github.com/Microsoft/PartsUnlimited/tree/aspnet45

Step 6. Clone the repo in the MSIT project

image

image

If you get the error:

“Error encountered while cloning the remote repository: Response status code does not indicate success: 404 (Not Found).”

Go back to manage connections and double click the partsunlimited collection which will allow you to clone the repo

image

 

Step 6. Create a local branch so you aren’t working in master. Click on branches in Team Explorer>Right click on Master >New Local Branch From…

Please name the branch something with your email address so you will remember it.

image

If you cloned the GitHub repo it will look like the following:

image

Step 7. If you are prompted for checkin credentials do and click update

image

Step 7. Open the PartsUnlimited.sln solution by double clicking on it….You can verify it is opened by manually switching to solution explorer –but there is no need

clip_image001

Step 7. If you get the error: This version of Visual Studio is unable to open the following projects

Then you probably need the Azure 2.6 SDK. Please download the Web Platform Installer.

For more information please see:

http://blogs.msdn.com/b/charles_sterling/archive/2015/06/17/this-version-of-visual-studio-is-unable-to-open-the-following-projects-deployproj.aspx

(Yes we are getting the documentation updated!)

image

Step 8. Make sure and publish the branch back to VSO so the build definition can see this branch.

If the option is grayed out like in the screen shot you have not created the local branch

Make sure and publish the branch you created!

image

 

Step 9. Right-click the PartsUnlimitedWebste project and then BUILD to pull down all the Nuget packages and everything is ready for creating the build.

image

Step 10.  If you try running the application locally and see this error:

An exception of type 'System.Data.SqlClient.SqlException' occurred in mscorlib.dll but was not handled in user code

It means you there is something wrong with your default connection…verify it is set to:

<add name="DefaultConnectionString" connectionString="Server=tcp:partsdb.database.windows.net,1433;Database=PartUnlimitedDB;User ID=AdminUser@partsdb;Password=P2ssw0rd;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"
  providerName="System.Data.SqlClient" /
>

image

 

Creating the CI Build

Step 1.  Now that the project is building, it is time for the easy part…creating the build. Log into a Visual Studio Online Account: https://partsunlimited.visualstudio.com/

and select the MSIT team project.

image

Step 2. Navigate to the MSIT team project by clicking the “Browse” link.

image

Step 3. Select the “Build” Menu.

NOTE Build.Vnext and Build has been merged you will NO longer see the build Build.Vnext as a separate option.

The legacy builds are now called XAML builds and new builds are simply called just “Builds”.

Step 4. Create a new Build. Click the Action button (Green Plus) to create new build definition

Please name this with your email address so you can find it later

image

Step 5.  As you can see, you can now do Xamarin Android/IOS and Builds as well as Xcode builds. Click on Visual Studio Build under the Build tab on the Definition Templates dialog.

image

Step 6. As we have multiple repos and branches, so we need to select the correct Repo and Branch before we can select which Solution to build.  If you had created a branch Click on the Repository tab and Select the repository you created above. If you didn’t create a branch just select Master.

image

Step 7.  Now we’re going to select the solution we’re going to build.  Click on the Build tab and Click the ellipsis in the Build Solution pane and select the PartsUnlimited.sln file.

image

Step 8.  There is an issue in Visual Studio 2015 RC and 2013 Update 5 that SLN Files are not automatically added to the files that are included in version control for Git that is getting fixed for the release.  If you don’t see the Partsunlimited.sln file go back to Visual Studio > Team Explorer > Changes. Scroll down to Untracked changes and add the PartsUnlimited.SLN, checkin, and sync the changes

image

Step 9. Configure the build definition to build the Publish package. This is done by specifying an msbuild argument

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=c:\agent\PartsUnlimitedWebsite.zip

 

I have noticed Livewriter truncates strings –here is the entire line:

/p:DeployOnBuild=true /p:WebPublishMethod=Package

/p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true

/p:PackageLocation=c:\agent\PartsUnlimitedWebsite.zip

 

image

Step 10.  So that the Build fires off every time there’s a check in, enable the Continuous integration trigger. You can select which branch you wish to monitor, as well. On the trigger tab of the build definition select “Continuous Integration”.

image

Step 11. Save the build with a name containing your email address that you will remember

image

Step 12. Test the CI Trigger.

1. In Solution Explorer, open PartsUnlimitedLite/Views/Home/index.cshtml

2. Make a small but visible change, e.g. in the <h1> title text.

Save the file

image

Step 13.   Check in the change

1. Open Team Explorer

2. Click the Home button

3. Click the Changes button

4. Enter a Commit message

Click Commit

image

Step 14.  Sync changes back to the server.  In Team Explorer, click the link to Sync changes back to the server

Click the Sync button to perform the sync operation.

 

Step 15. In the PartsUnlimited.Visualstudio.com under the build tab, you will that your CI build had been queued.

image

Step 16 Let’s see how the build is doing. You can see the Build steps and the details in this panel. Double click on the queued build.

2. Monitor the build process and confirm that completes successfully.

image

 

Verify the change made it to the site:

image

 

Be sure and check out the other labs:

 

 

 

Tuesday we are doing a DevOps Lab for MSIT and wanted to streamline/tune the walk through for this internal audience.

In this lab, you will learn about the four of the five major DevOps Enablers:

  1. Continuous Integration
  2. Continuous Deployment
  3. Continuous Testing
  4. Application Monitoring

This lab will be the second in that series-setting up Continuous Deployment using Visual Studio Release Management

Now that we have our CI build working and creating the Web Deploy package. It is time to get set up continual deployment in a release pipeline.  Note: at the time of authoring this document Release Management was not available publically in VSO….you will have to use  shared account  https://partsunlimited.visualstudio.com/DefaultCollection/MSIT/_releasepipeline 

Step 1. In Visual Studio Online click on the Release Hub. Note: if you don't see you "Release" in your Visual Studio Online account it is due to the fact it is still hidden with a feature flag and you will have to have the lab proctor add you to the PartsUnlimited VSO Account.

image

Step 2.  Click the Action button (Green Plus) to create new release definition

Please name this with your email address as it is likely we will be creating lots of release!

image

Step 3. The stereotypical dev team will have three environments…lets create those.  Click the Action button (Green Plus) for environments twice…giving us a total of three environments.

Name the environments:

a. Dev

b. QA

c. Prod

image

Step 4.   You will note there are lots of options for deploying your build, running Tests  and giving you insight into your build process as part of the build.  Lets set that up:

1. Select the "Dev" Environment

2. Click the Action button (Green Plus) for tasks (see image above) select the "Test" category and add a task that runs all unit tests in the solution on the build controller.

image

Step 5. Setup up the Test task…while there is no specific actions here it is worth reviewing the options for running tests…

Step 6. Setup the Dev environment as part of the release deployment.  Click the Action button (Green Plus) for tasks (see image above) select the "Deployment" category and add a task that deploys an Azure Website

image

Step 7.  Set Azure Web Site Deployment task.  For Azure subscription set it to use the parts unlimited sponsorship, set the web site location to be West US, set the website name to PartsunlimitedwebDev and the package to be the package we are created in the CI Lab:

c:\agent\PartsUnlimitedWebsite.zip

image

Step 8. Add Approvers to the QA Environment step of the build release.  So that bad builds or content doesn’t show up unexpectedly you can set up approvers.  To do this right click on the environment and choose Assign Approvers.

image

Step 9. Add Approvers to the Pre-deployment stage of the QA –Environment.

NOTE: Make and sure and the account you are logged in with or you will have to reassign the approver to complete this build

image

Step 10.  Add task and go to the "Test" category

image

Step 11. Add Load Testing to the QA Environment

image

Step 12. Setup the Test environment as part of the release deployment.  Select the QA environment. Click the Action button (Green Plus) for tasks (see image above) select the "Deployment" category and add a task that deploys an Azure Website

image

Step 13.  Set Azure Web Site Deployment task.  For Azure subscription set it to use the parts unlimited sponsorship, set the web site location to be West US, set the website name to PartsunlimitedwebTest and the package to be the package we are created in the CI Lab:

c:\agent\PartsUnlimitedWebsite.zip

Step 14. Setup the Prod environment as part of the release deployment.  Select the Prod environment and Click the Action button (Green Plus) for tasks (see image above) select the "Deployment" category and add a task that deploys an Azure Website

image

Step 13.  Set Azure Web Site Deployment task.  For Azure subscription set it to use the parts unlimited sponsorship, set the web site location to be West US, set the website name to Partsunlimitedweb and the package to be the package we are created in the CI Lab:

c:\agent\PartsUnlimitedWebsite.zip

Step 9. Save the Release Definition

image

Step 10. If you cannot save the release make sure the account is in the release managers group.  To add your account to the Release managers group click on the gear.  Click on Security tab.

image

Step 12. Select Release Managers > Members > Add and add the account you are logged in with

image

 

Step 13.  Now that all the components of this release pipeline are completed it is time to set it to run on the completion of a build. Click on Triggers

image

Step 14. Check the check box for continuous deployment and select the build you created above

image

Step 15 As a test it is probably worth verifying your release pipeline will work when started manually.  Click the Action button (Green Plus) to create new release.

image

Step 16. This will prompt you which build do you want to run the release on…Choose a build and select "Create"

image

Step 17. Check the status.  Open the Release by selecting the hyperlink for that Release.

 image

image 

Step 18. If you remember earlier in the lab, the release has an approval step in it.  Select the release hyper link you just created above and select "logs"

  image

Step 19.  Approve the release to the QA environment

image

Step 20.  Review the Release

 

image

 

Tuesday we are doing a DevOps Lab for MSIT and wanted to streamline/tune the walk through for this internal audience.

In this lab, you will learn about the four of the five major DevOps Enablers:

  1. Continuous Integration
  2. Continuous Deployment
  3. Continuous Testing
  4. Application Monitoring

 

Testing in Continuous Integration and Continuous Deployment Workflows

At a high level DevOps is a focus on increasing customer value by reducing cycle times in the development process.  As a result of these faster cycle times testing can be challenging. This section we will look at integrating testing into CI/CD pipelines using to ensure less friction in the testing process and a high quality application.   While there are use cases to do this as part of the CD or CI pipeline this walk through will focus on the integration as part of the CI Build process.

 

Step 1. Creating a machine group.  Machine groups are how the test efforts are scaled across multiple machine and in environments and make up the one of the core building blocks for continuous testing.  To get started, in the Test menu, click on the machines menu.  Click the Action button (Green Plus) to create a new machine group.  If you doing this as part of my lab and running low on time consider reusing the Xlab Machine Group that already exists. Even if you do decide to reuse the the preexisting xlab Machine Group as the corner stone of the Testing CI features please at least open the Test hub and the “Machines” menu.  Select the Test CI machine group and select edit and take a look at the definition.  

image

Step 2.  Adding Machines to a machine group. To enable testers to very easily run the same test against multiple machines we can add several computers to a machine group.  For user name type in your domain credentials in the DOMAIN\NAME syntax.  For The machine name, please enter an IP Address or FQDN i.e. 4TestCI1.redmond.corp.microsoft.com

image

There several caveats for computers to be used with this early version of the Test CI agent and workflow.

  1. We do not have the support for test machines residing in Azure yet. However this is coming soon.
  2. We do not support the Hosted Build controller.
  3. The build agent and test agent machines should be on-premises machines and the build machine should be able to communicate with the target test machine.
  4. The build agent being used for the Test CI tasks must be domain joined
  5. The computer being added the machine group must be domain joined
  6. Need to enable winrm on your test agent machine (run winrm quickconfig to enable this)
  7. We do not support use of the “hosted” build pool for the Test CI tasks
  8. Do not install test agents for visual studio 2015 on a machine with VS2015RC.  There is known issue here that we have fixed for RTM.

Step 3. Edit the Build definition to Add the Test CI Tasks to the CI Pipeline. In this lab we will already have created a CI build.  To save yourself some time right click on this build definition and select “Edit”.

 image

Step 4. Add the tasks to enable Continuous Testing.  For this lab we will be enabling continuous testing with the three tasks: Test Agent Deployment, Copy the Test files, Test using the Test Agent.  To get started click the green action button next to “Add build step….” (see image above) .  Add the three steps listed above.  You will find the the “Windows Machine File Copy” under the “All category.  To save time on subsequent runs you should go into the “Advance” options and deselect “Check for Updates”.

 

image

image

 

Step 5 Configure the Deploy Agent step.  The Agent deploy step requires three pieces of information: Machine Group (either the one you created above use the group already created called: xlab, a username variable and a password variable….no your password is not stored in clear text!!! The syntax to reference these variables is:  $(varname). While the variables in this lab are called “username” and “password”…they could have been called practically anything.

image

Step 6. Creating the username and password variables.

The deployment agent requires the user and password be accessed via a variable.  To create these two variables click the “Variable” menu and press the green “Add variable” action button to add both of these variables and to protect your password click the “lock” icon.

image

Step 6 Copying the Test Files to the Agents.  If the Agent deployment step succeeds we will want to copy the binaries to all the machines in the machine group. This task requires three parameters: the source, the machine group and the path to be copied to.

1. The source references all the build all the assets with the argument: $(Build.Repository.LocalPath)

2. The machine group to be used xlab

3. The path on the agent you want the files copied to…to make it easy for this lab the agent machine has a directory called: c:\drops

image

Step 7 Configure the run with Agent.  Now that the agent is installed into the machines in the machine group and the files have been copied across it is time to run the test.  This Build task only requires two parameters: the machine group (xlab) and the file path (c:\drops).  Also as it is likely some of the unit tests will fail select the option “Continue on Error”.

image

Step 8 Running the build. At this point we have set up everything to run test on an assortment of machines every time a build is started.  To start the build click the menu: “Queue build….” this can be done from the edit menus or right clicking on the build definition.  It is important that you select a locally managed queue as continuous testing is NOT supported on the hosted queue/agent.

image

Step 9 Monitoring the execution. At this point the build will start and you see in real time what steps are executing and their status.

image

If you build succeeds except for the test execution you may have forgot to toggle the option: “Continue on Error:”.  Toggle this and reruning the build should give you a status like the one below.

image

image

Step 11. Viewing the test results.  Opening the build run you will see the results of the run such as the commits, tags, issues and in data we are interested in –Test Results.  Clicking on this Test results will take you the Test>Runs and opens that run ID.

image

 

Step 12: Viewing the Test run Data.  By selecting the “Test results” menu you can drill down into the test data.  In this case it looks like we may have issues with specific environments/browsers.


Comments (1)

Skip to main content