Add Environment, Set Variables and Approvals for a Release in VSTS
In this lab we will add an additional environment and change our variables, then add approvals to our release process.
DevOps MPP Course Source
- This lab is used in course DevOps200.6x: DevOps for Databses - Module 3.
Prerequisites:
- Completion of the Module 3 labs Creating a Release Process with either State-Based or Migration-Based development.
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.
-
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.
-
Click the Release WWI definition, then click the Edit link in the upper middle.
-
We will create a new environment and set different variables. Click the ellipsis in the QA environment box and click Clone Environment.
-
A dialog will appear with some properties for this environment. Uncheck the Deploy Automatically check box, then click Create.
-
This will duplicate all of the environment settings, including the tasks. Click Copy of QA and change this to say Staging.
-
For the ReadyRoll task properties, change the target database to WWI_Staging.
-
Click on the ellipsis beside Staging, then click Configure variables.
-
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.
-
Click Save to save the task. Enter a comment, then click OK.
-
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.
-
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.
-
Click the ellipsis under Actions for the Staging environment, then click Deploy.
-
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.
Task 2: Adding a manual approval to a release
We will set up a manual approval gate for releases.
-
Open your VSTS account. From the Build&Release menu at the top, click Releases. You should see the three release definitions.
-
Click the Release WWI definition, then click the Edit link in the upper middle.
-
Click the ellipsis next to the Staging environment and click Assign approvers.
-
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.
-
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.
-
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.
-
Click Save, enter a comment, then click OK.
-
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.
-
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.
-
After you confirm the release, a yellow bar should appear below the menu, asking for an approval.
-
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 release should complete and show successful. Verify the release, by examining the database in SQL Server Management Studio.
Summary
In this lab you have completed the following tasks:
- Added a new environment for release
- Added a manual approval to a release