<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Divyansh Manchanda’s Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/divman/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/divman/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:51:07 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Understanding states in Release Management</title>
      <link>https://docs.microsoft.com/archive/blogs/divman/understanding-states-in-release-management</link>
      <pubDate>Tue, 25 Jul 2017 18:08:32 GMT</pubDate>
      <dc:creator><![CDATA[Divyansh Manchanda]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/divman/?p=55</guid>
      <description><![CDATA[Trying to code against release management APIs? This post will try to demystify the various states...]]></description>
      <content:encoded><![CDATA[Trying to code against release management APIs? This post will try to demystify the various states that are present in the release object and explain what each of them signify.

First, we need to understand the structure of the release object. The release object is a wrapper to a bunch of artifacts and environments. Each environment is what actually gets deployed - and the artifact gives away the details of what got deployed (the bits). The properties that we are mainly concerned with are shown here with the hierarchy -

Release
- Environments (List of ReleaseEnvironment)
<span>     </span><span>     </span>&lt;ReleaseEnvironment&gt;
<span>     </span><span>     </span><span>     </span>- DeploySteps (List of DeploymentAttempt)
<span>     </span><span>     </span><span>     </span><span>     </span>&lt;DeploymentAttempt&gt;
<span>     </span><span>     </span><span>     </span><span>     </span><span>     </span>- ReleaseDeployPhases
<span>     </span><span>     </span><span>     </span><span>     </span><span>     </span><span>     </span>- ManualInterventions (if any)
<span>     </span><span>     </span><span>     </span><span>     </span>&lt;/DeploymentAttempt&gt;
<span>     </span><span>     </span><span>     </span>- PreDeploy Approvals
<span>     </span><span>     </span><span>     </span>- PostDeploy Approvals
<span>     </span><span>     </span>&lt;/ReleaseEnvironment&gt;

A release contains a list of release environments. Each release environment has some static information around what is to be run- the list of tasks and settings. The environment in turn has a list of deploy steps, one per deployment attempt. A deployment attempt is the run time entity which will contain the results of execution of each task. Lets look at the states of each of these layers and figure out what each of them means.

<span style="text-decoration: underline"><strong>Release</strong></span><strong> </strong>(release.status)
<ul>
 	<li><strong>Draft</strong> - The release was created as a draft and no deployment has started yet. You can edit the release object just like you would edit the release definition and then start the release. Any edits made to the release will not impact the release definition.</li>
 	<li><b>Active - </b>Once a release has been started it enters the active state. Either deployments are going on the environments or they are waiting to start through an external trigger like a manual deploy action or completion of the previous environment. A release needs to be in active state for users to perform actions on it. An active release has an aritfact linked to it which cannot be modified.</li>
 	<li><strong>Abandoned</strong> - This is the terminal state of the release. No more actions are allowed on abandoned releases.</li>
</ul>
<span style="text-decoration: underline"><strong>Release Environment</strong></span> (environment.status)
<ul>
 	<li><strong>NotStarted</strong> - No deployment has been queued on this environment. Some external signal needs to come in to start the deployment, be it a manual trigger or the completion of some previous environment.</li>
 	<li><strong>InProgress</strong> - The environment has moved out of the pipeline queue. The execution has begun. Do note: the enviroment is in either of the 3 states - pre deployment approval, deploying, post deployment approval.</li>
 	<li><strong>Succeeded</strong> - All good!</li>
 	<li><strong>Canceled</strong> - The deployment on the environment has been canceled by some user.</li>
 	<li><strong>Rejected</strong> - An apporoval was rejected.</li>
 	<li><strong>Queued</strong> - If the queuing policy on the environment is configured in a way that deployment has to wait, the environment state would be marked as queued.</li>
 	<li><strong>Scheduled</strong> - A deployment is scheduled for some later time. (environment.nextScheduledTime will tell you when)</li>
</ul>
ReleaseEnvironment gives you some information as to where exactly is the deployment as of now. These states are too broad and you would still need to parse the object if you need meaningful info like - "environment is in progress, but is it safe to cancel the deployment now or are the tasks executing already?". To answer questions like these you need to look at the deploymentAttempt object. The deployment attempt object list contains all the run time information about the attempts that were made to deploy to an environment within a release. Every time you click on the deploy/redeploy button the environment a new deploymentAttempt is created.

<span style="text-decoration: underline"><strong>DeploymentAttempt</strong></span> (status, operationStatus)

<strong></strong>This object has a status and an operationStatus. The status will be like the environment status (broad classification) and the operationStatus will tell you why the deployment is in that state. This is to be read in &lt;status, operationStatus&gt; pairs -
<ul>
 	<li><strong>&lt;NotDeployed, Queued&gt;</strong> - Queued because of the queueing policy (eg. For "one deployment should be active at a time" policy, the newer deployments will be in this state)</li>
 	<li><strong>&lt;NotDeployed, Scheduled&gt;</strong> - Environment is scheduled for deployment at a later time.</li>
 	<li><strong>&lt;NotDeployed, Pending&gt;</strong> - Pre deployment approval is pending.<em> environment.predeployApprovals</em> will tell you who is blocking it.</li>
 	<li><strong>&lt;NotDeployed, Approved&gt;</strong> - Pre deployment approval just got approved. The deployment should not be stuck here for long and will move forward automatically.</li>
 	<li><strong>&lt;NotDeployed, Rejected&gt;</strong> - This is when the pre depoyment approval got rejected by the user. Again, <em>environment.predeployApprovals</em> will tell you who rejected it.</li>
 	<li><strong>&lt;NotDeployed, Deferred&gt;</strong> - The approver did approve the deployment but deferred it to a later time.</li>
 	<li><strong>&lt;NotDeployed, QueuedForAgent&gt;</strong> - The deployment is ready to run but there is no free agent and it is stuck in the agent queue.</li>
 	<li><strong>&lt;NotDeployed, QueuedForPipeline&gt;</strong> - Oops, you ran out of licenses. The deployment will proceed when a pipeline gets freed up.</li>
 	<li><strong>&lt;NotDeployed, Canceled&gt;</strong> - The deployment got canceled before the task execution ran. <em>deployStep.LastModifiedBy</em> will tell you who canceled the deployment.</li>
</ul>
Do note, the deployment status is marked as <strong>InProgress</strong> only when the agent picks up task execution. The environment.state on the other hand is marked as inprogress as soon as the pre-approval is created.
<ul>
 	<li><strong>&lt;InProgress, PhaseInProgress&gt;</strong> - The deployment got picked up by the agent. Task execution has started.</li>
 	<li><strong>&lt;InProgress, ManualInterventionPending&gt;</strong> - You had a manual intervention task and the deployment now tells you that. <em>deployStep.releaseDeployPhases[x].ManualInterventions</em> collection will have more details on the manual intervention.</li>
 	<li><strong>&lt;InProgress, PhaseSucceeded&gt;</strong> - The deploy phase passed. The next deploy phase would begin execution or a post deployment approval will be created.</li>
 	<li><strong>&lt;InProgress, Pending&gt;</strong> - All deploy phases have completed execution. The deployment is waiting on a post-deployment approval.</li>
 	<li><strong>&lt;InProgress, QueuedForAgent/QueuedForPipeline&gt;</strong> - The difference between this and &lt;NotDeployed, Queued...&gt; is that this will be the state for all phases after the first one has finished execution.</li>
 	<li><strong>&lt;Succeeded, Approved&gt;</strong> - Yay! All good, tasks passed and approvers approved the release.</li>
 	<li><strong>&lt;PartiallySucceeded, PhasePartiallySucceeded&gt;</strong> - A task that was marked as <em>ContinueOnError</em> failed. The subsequent tasks executed successfully.</li>
 	<li><strong>&lt;Failed, PhaseFailed&gt;</strong> - Task failed, or the manual intervention got rejected.</li>
 	<li><strong>&lt;Failed, Canceled&gt;</strong> - Someone canceled the deployment after the task execution started and before the deployment could go green. If tasks were executing when this happened <em>environment.PostDeployApprovals</em> should be empty, and if the deployment got canceled when it was pending an approval the collection would have an entry. <em>deployStep.LastModifiedBy</em> will give away details on who canceled the deployment.</li>
 	<li><strong>&lt;Failed, Rejected&gt;</strong> - A post deploy approval got rejected.</li>
</ul>
[Update]

There were a few more states introduced in RM so i'm updating the blog to reflect those as well.
<ul>
 	<li><strong>&lt;InProgress, Cancelling&gt;</strong> - This is the intermediate state between &lt;inProgress, PhaseInProgress&gt; and &lt;Failed, Cancelled&gt; and happens when a user issues the cancel signal when tasks are executing. The deployment is most likely completing some pending operations before the terminal failed state can be reached. (eg. finish tasks marked as alwaysRun)</li>
</ul>
States related to RM gates functionality
<ul>
 	<li><strong>&lt;NotStarted, EvaluatingGates&gt; </strong>- Pre deployment gates being evaluated.</li>
 	<li><strong>&lt;NotStarted, GatesFailed&gt; </strong>- Pre-deployment gates evaluation failed. Whether this is a terminal state or not depends on the gates options (ask for approval always setting will move the release forward)</li>
 	<li><strong>&lt;InProgress, EvaluatingGates&gt; </strong>- Post-deployment gates being evaluated.</li>
 	<li><strong>&lt;InProgress, GatesFailed&gt; </strong>OR<strong> &lt;Failed, GatesFailed&gt;</strong> - Post-deployment gates evaluation failed. Whether this is a terminal state or not (InProgress or Failed status) depends on the gates options (ask for approval always setting will move the release forward).</li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Adding release management environment templates to your VSS extension</title>
      <link>https://docs.microsoft.com/archive/blogs/divman/adding-release-management-environment-templates-to-your-vss-extension</link>
      <pubDate>Tue, 30 May 2017 17:50:31 GMT</pubDate>
      <dc:creator><![CDATA[Divyansh Manchanda]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/divman/?p=35</guid>
      <description><![CDATA[One of the easiest way to create a Release Definition is by using a pre-created environment...]]></description>
      <content:encoded><![CDATA[One of the easiest way to create a Release Definition is by using a pre-created environment template. If you have ever authored a release definition, you would have seen this pop-up while adding a new environment -

<img src="https://msdnshared.blob.core.windows.net/media/2017/05/template-270x300.jpg" alt="" width="270" height="300" class="alignnone size-medium wp-image-45" />

This lets you choose a template from system templates, or you can save your own environment as a template and re-use them while creating new environments. As an author of a vss extension <em>you can now define environment templates which will be available to all users when they install the extension</em>.

<strong>Steps to add an environment template to your extension</strong>
<ol>
 	<li>The contribution that the extension needs to target to add environment templates is <strong>ms.vss-environmenttemplate.environment-template</strong></li>
 	<li>All the changes to describe this template go to vss-extension.json file of the extension.</li>
 	<li>Define your template with the following properties (the payload looks like any other environment template) -
<ul>
 	<li>Id - A guid to uniquely identify your environment template.</li>
 	<li>Name - Name of the template that will show up in the popup shown above.</li>
 	<li>Description - Describe what the template can do</li>
 	<li>Variables - A set of RM variables that the environment will be set up with.</li>
 	<li>DeployPhases - A list of the deploy phases that will be executed when the deployment begins. Each deploy phase will have its own set of tasks to be executed by the agent.</li>
</ul>
</li>
 	<li>Add an icon to represent the template.</li>
 	<li> Build and install the extension! The template should be available in templates list now.</li>
</ol>
<a href="https://github.com/Microsoft/vsts-rm-extensions/tree/master/Extensions/EnvironmentTemplateSample">Link </a>to the Release Management extensions repo on GitHub that has a sample extension published.

If you are new to writing extensions, this <a href="https://www.visualstudio.com/en-us/docs/integrate/extensions/get-started/node">link </a>will be useful.]]></content:encoded>
    </item>
    <item>
      <title>Hello world!</title>
      <link>https://docs.microsoft.com/archive/blogs/divman/hello-world</link>
      <pubDate>Tue, 30 May 2017 10:39:47 GMT</pubDate>
      <dc:creator><![CDATA[Varsha G]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/divman/?p=1</guid>
      <description><![CDATA[Welcome to Developer Network. This is your first post. Edit or delete it, then start blogging!]]></description>
      <content:encoded><![CDATA[Welcome to <a href="https://blogs.msdn.microsoft.com/">Developer Network</a>. This is your first post. Edit or delete it, then start blogging!]]></content:encoded>
    </item>
  </channel>
</rss>