{"id":623,"date":"2014-10-10T03:32:00","date_gmt":"2014-10-10T03:32:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2014\/10\/10\/trigger-release-from-build-with-release-management-for-visual-studio-2013-update-3\/"},"modified":"2022-05-26T05:28:45","modified_gmt":"2022-05-26T13:28:45","slug":"trigger-release-from-build-with-release-management-for-visual-studio-2013-update-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/trigger-release-from-build-with-release-management-for-visual-studio-2013-update-3\/","title":{"rendered":"Trigger Release from build with Release Management for Visual Studio 2013 Update 3"},"content":{"rendered":"<p><span style=\"color: #ff0000\">The following is applicable only for vNext pipelines of Release Management.\u00a0<\/span><\/p>\n<p><span style=\"color: #ff0000\">\u00a0<\/span><\/p>\n<p>To trigger a release from build with Release Management for Visual Studio 2013 <strong>Update 2<\/strong>, you needed to install RM client on TFS build agent machine.\u00a0 With <strong>Update 3<\/strong>, this is no longer needed. Release Management Update 3 has exposed some REST APIs to trigger release from TFS build agent machine without installing RM client. You can now write ps script using these REST APIs. You can then include this ps script in post build activity of build definition, to trigger a release with a new successful build.<\/p>\n<p>The APIs\u00a0<strong>InitiateReleaseFromBuild **and<\/strong>\u00a0****InitiateRelease\u00a0**can be used to trigger a release. Both these APIs return releaseId for that release. You can use this releaseId to get release status or Stop or Abandon the release.<\/p>\n<p><em>If release definition has \u201cBuild with Application\u201d or \u201cBuild Independently\u201d component, the following API can be used to trigger release for that release definition from build definition.<\/em><\/p>\n<ol>\n<li>http:\/\/RMSERVER:PortNumber\/account\/releaseManagementService\/_apis\/releaseManagement\/OrchestratorService\/<\/li>\n<\/ol>\n<p><strong>InitiateReleaseFromBuild<\/strong>?teamFoundationServerUrl=\u201d<span style=\"color: #ff6600\"><em>tfsserverurl<\/em><\/span>&#8220;&amp;teamProject=&#8221;<span style=\"color: #ff6600\"><em>project<\/em><\/span>&#8220;&amp;buildDefinition=&#8221;<span style=\"color: #ff6600\"><em>definition<\/em><\/span>&#8220;<\/p>\n<p>&amp;buildNumber=&#8221;<span style=\"color: #ff6600\"><em>build<\/em><\/span>\u201d&amp;targetStageName=&#8221;<span style=\"color: #ff6600\"><em>targetStage<\/em><\/span>\u201d<\/p>\n<p><em>If release definition has \u201cBuilds externally\u201d components, the followoing API can be used to trigger a release for a given release definition from build definition.<\/em><\/p>\n<p>2&#46;\u00a0http:\/\/RMSERVER:PortNumber\/account\/releaseManagementService\/_apis\/releaseManagement\/OrchestratorService\/<\/p>\n<p><strong>InitiateRelease<\/strong>?releaseTemplateName=<em><span style=\"color: #ff6600\">&#8220;releaseDefinition<\/span><\/em>&#8220;&amp;deploymentPropertyBag=&#8221;<span style=\"color: #ff6600\"><em>propertyBag<\/em><\/span>&#8220;&amp;api-version=2.0<\/p>\n<p>\u00a0<\/p>\n<p>Here are other APIs which can be used to get additional details w.r.t. a release. Note that these take a releaseId which is output of the above APIs.<\/p>\n<ol>\n<li>http:\/\/RMSERVER:PortNumber\/account\/releaseManagementService\/_apis\/releaseManagement\/OrchestratorService\/<\/li>\n<\/ol>\n<p><strong>AbandonRelease<\/strong>?releaseId=<span style=\"color: #ff6600\"><em>releaseId<\/em><\/span>&amp;api-version=2.0<\/p>\n<ol>\n<li>http:\/\/RMSERVER:PortNumber\/account\/releaseManagementService\/_apis\/releaseManagement\/OrchestratorService\/<\/li>\n<\/ol>\n<p><strong>StopRelease<\/strong>?releaseId=<span style=\"color: #ff6600\"><em>releaseId<\/em><\/span>&amp;api-version=2.0<\/p>\n<ol>\n<li>http:\/\/RMSERVER:PortNumber\/account\/releaseManagementService\/_apis\/releaseManagement\/OrchestratorService\/<\/li>\n<\/ol>\n<p><strong>ReleaseStatus<\/strong>?releaseId=<span style=\"color: #ff6600\"><em>releaseId<\/em><\/span>&amp;api-version=2.0<\/p>\n<p><em>(Note: the above urls are put in 2-3 lines for readability. Read them as 1 line API)<\/em><\/p>\n<p style=\"padding-left: 30px\">\n<p>You can find an attached sample script in the zip file named <em>InitiateReleaseFromBuild.ps1<\/em>, which takes RMserver, port number, teamproject and targetStage as parameters and triggers a release. Once release is triggered, it will wait till the release state changes from In progress to Released \/ Rejected state.<\/p>\n<p>The following snapshot showcases the way to call* InitiateReleaseFromBuild.ps1* from build definition:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/10\/5164.blog-1.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<p>The modified build template <em>TfvcTemplate.12.2.xaml<\/em> is attached, for reference.<\/p>\n<p>You can modify this script to trigger releases on multiple RM servers using same build. You can also add logic to abandon a release after a particular interval of time if the release does not complete.\u00a0 If you wish to fail a build if release fails, you should exit the powershell script with return value 1 upon failure. Exit with return value 0 to pass the build even on release failure.<\/p>\n<p>Attachment:\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/02\/Release-from-Build.zip\">Release from Build<\/a><\/p>\n<p>Related blogs:<\/p>\n<p><a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2014\/01\/31\/how-to-modify-the-upgradetemplate-xaml-to-enable-releasing-from-a-build.aspx\" title=\"How to modify the UpgradeTemplate.xaml to enable releasing from a build\">How to modify the UpgradeTemplate.xaml to enable releasing from a build<\/a><\/p>\n<p><a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/12\/09\/how-to-modify-the-build-process-template-to-use-the-option-trigger-release-from-build.aspx\" title=\"How to modify the TFS 2013 default build process template (GitTemplate.12.xaml &amp; TfvcTemplate.12.xaml) to enable releasing from a build\">How to modify the TFS 2013 default build process template (GitTemplate.12.xaml &amp; TfvcTemplate.12.xaml) to enable releasing from a build<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following is applicable only for vNext pipelines of Release Management.\u00a0 \u00a0 To trigger a release from build with Release Management for Visual Studio 2013 Update 2, you needed to install RM client on TFS build agent machine.\u00a0 With Update 3, this is no longer needed. Release Management Update 3 has exposed some REST APIs [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[253,226,1],"tags":[],"class_list":["post-623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-devops-server","category-ci","category-devops"],"acf":[],"blog_post_summary":"<p>The following is applicable only for vNext pipelines of Release Management.\u00a0 \u00a0 To trigger a release from build with Release Management for Visual Studio 2013 Update 2, you needed to install RM client on TFS build agent machine.\u00a0 With Update 3, this is no longer needed. Release Management Update 3 has exposed some REST APIs [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=623"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}