In this lab we will add an additional environment and change our variables, then add approvals to our release process.

DevOps MPP Course Source

Prerequisites:

Lab Tasks:

  • Add a new environment for release
  • Add a manual approval to a release

Estimated Lab Time:

  • approx. 30 minutes

Task 1: Add a new environment for release

We will add an additional environment and change our variables.

  1. Open your VSTS account. Click the Build&Release menu at the top, and then click Releases. You should see the two previous release definitions on the left and the results of your previously created releases in the main part of the page.

    On the Build & Release menu, on the Releases tab, in the left pane, All release definitions is selected. In the right pane, under All release definitions, three releases display: Release-2 (with Release Definition Release WWI), Release-1 (with Release definition Release WWI), and Release-1 (with Release Definition Release to Integration). Release-2 and the second Release-1 (Release to Integration) display with green check marks. However, the first Release-1 (Release WWI), displays with a red X.

  2. Click the Release WWI definition, then click the Edit link in the upper middle.

    In the left pane, under Release definitions, Release WWI is selected. In the right, Edit pane, on the Release tab, under Release, Release-2 is selected.

  3. We will create a new environment and set different variables. Click the ellipsis in the QA environment box and click Clone Environment.

    On the Definition:Release WWI / Releases page, on the Environments tab, in the left pane under Add environment, the ellipses for QA is selected. From its drop-down menu, Clone environment is selected.

  4. A dialog will appear with some properties for this environment. Uncheck the Deploy Automatically check box, then click Create.

    Under Add new environment, Pre-deployment approval is set to Automatically approve. Under Trigger, the check box is cleared for Deploy automatically whenever a deployment to the environment QA is successful.

  5. This will duplicate all of the environment settings, including the tasks. Click Copy of QA and change this to say Staging.

    On the Definition:Release WWI / Releases page, on the Environments tab, in the left pane under Add environment, the name for the new environment is Staging.

  6. For the ReadyRoll task properties, change the target database to WWI_Staging.

    On the ReadyRoll task properties page, under Deploy to .\SQL2016, the Target Database Name is now WWI_Staging.

  7. Click on the ellipsis beside Staging, then click Configure variables.

    The Staging ellipsis is selected, and from its drop-down menu, Configure variables is selected.

  8. Enter the following variables. These are the same variable names used for QA, but we will use different values for this environment.

    • DeployUser: VSTSReleaseStaging
    • DeployPwd: The password you entered in the first module 3 lab section.

    On the Configure – ‘Staging’ environment page, on the Variables tab, values are set to the previously defined values.

  9. Click Save to save the task. Enter a comment, then click OK.

    The Comment box displays the message, Added staging environment.

  10. From the drop-down menu beside Release, click Create Release as you did in the first Module 3 lab. Note that this time there is a manual deployment for the staging environment. Click Create.

    On the Create new release for Release WWI page, under Artifacts, WideWorldImporters-RR-CI (Build) is set to version 5. Under Automated deployments, the deployment trigger for the QA environment is set to Automated deployment: After release creation.

  11. Click the release in the blue bar and notice that the QA environment is in progress. This will complete, but the Staging environment will not start.

    On the Release WWI / Release-3 page, on the Summary tab, under Environments, the QA environment deployment status is Succeeded. The Staging environment deployment status, however, is Not Deployed. Under Actions, the Staging ellipses drop-down menu displays, and Deploy is selected.

  12. Click the ellipsis under Actions for the Staging environment, then click Deploy.

    On the Deploy Release-3 to Staging page, under Artifacts, WideWorldImporters-RR-CI/5(Build) master displays. At the bottom, the Deploy button is selected.

  13. After the deployment completes, you should see a success message. This deployment used the same variable for the release, but with a different value for this environment.

    Next to Staging, the Succeeded message displays.

Task 2: Adding a manual approval to a release

We will set up a manual approval gate for releases.

  1. Open your VSTS account. From the Build&Release menu at the top, click Releases. You should see the three release definitions.

    Under Build & Release, on the Releases tab, in the left, Release Definitions pane, All release definitions is selected. In the right pane, under all release definitions, on the releases tab, three releases display: Release-2, Release-1, and Release-1.

  2. Click the Release WWI definition, then click the Edit link in the upper middle.

    In the left, Release Definitions pane, Release WWI is selected. In the right pane, the Edit link is selected.

  3. Click the ellipsis next to the Staging environment and click Assign approvers.

    On the Definition: Release WWI / Releases page, In the left, Add environment pane, the Staging ellipsis is selected. From its drop-down menu, Assign approvers is selected.

  4. A dialog appears that allows us to choose whether we want automatic approvals or assign specific users. Select Specific Users for the Pre-deployment approver. Begin searching your own account name and it should appear. Select it.

    On the Configure – ‘Staging’ environment page, on the Approvals tab under Approvers, the Specific Users radio button is selected for Pre-deployment approver, and sjones is selected.

  5. You can optionally check the box to send an email to the user. The lower check box is useful if a group of people are used to approve the release, but you do not want a person to approve their own release.

  6. Click the Deployment conditions tab at the top. We can set triggers that automatically approve this release after successful deployment to another environment. Select this radio button. The QA environment can be selected if you would like to add a gate that prevent deployment to staging unless a deployment has been made to QA.

    Return the radio button to the No Automated Deployment selection, then click OK.

    Under Trigger, under Define the trigger that will start deployment to this environment, the radio button is selected for After successful deployment to another environment, and the Triggering environment(s) field is set to QA.

  7. Click Save, enter a comment, then click OK.

    Under Save, the Comment field displays the message, "Added an approver to staging releases."

  8. Return to Visual Studio and add a new migration script with this code:

     ALTER TABLE sales.Regions
     ADD Active BIT;
    

    Save the script, click Deploy Project and then using Team Explorer, select Changes, enter a comment, click Commit All and Push to push the code to VSTS. A new build and release should occur.

  9. After the release to integration is complete, select Release WWI and create a new release as you did earlier in the lab. The new release will deploy to QA automatically. After the release is complete, click Deploy to Staging.

    On the Release WWI / Release-5 page, on the Summary tab, under Environments, the ellipses for Staging is selected. From its drop-down menu, Deploy is selected.

  10. After you confirm the release, a yellow bar should appear below the menu, asking for an approval.

    On the Release WWI / Release-5 page, on the Summary tab, the message “A pre-deployment approval is pending for ‘Staging’ environment. Approve or Reject” displays. The Approve or Reject part of the message is a live link.

  11. Click Approve and the approval dialog appears. The dialog appeared because you selected your account as an approver for this environment. You can type a comment about this release, reassign the approval to another, and potentially defer this deployment. Click Approve.

    The Pre-deployment approval pending dialog box displays.

  12. The release should complete and show successful. Verify the release, by examining the database in SQL Server Management Studio.

    In SQL Server Management Studio, the Columns folder is expanded, and RegionID, RegionName, and Active display.

Summary

In this lab you have completed the following tasks:

  • Added a new environment for release
  • Added a manual approval to a release