{"id":38869,"date":"2020-04-14T06:00:48","date_gmt":"2020-04-14T13:00:48","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/premier-developer\/?p=38869"},"modified":"2020-03-25T11:51:45","modified_gmt":"2020-03-25T18:51:45","slug":"azure-devops-pipelines-multi-stage-pipelines-and-yaml-for-continuous-delivery","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/azure-devops-pipelines-multi-stage-pipelines-and-yaml-for-continuous-delivery\/","title":{"rendered":"Azure DevOps Pipelines \u2013 Multi-Stage Pipelines and YAML for Continuous Delivery"},"content":{"rendered":"<p>In this post, App Dev Manager <a href=\"https:\/\/www.linkedin.com\/in\/tayloromalley\/\">Taylor O\u2019Malley<\/a> gives a walkthrough of Multi-Stage YAML pipelines for CI\/CD.<\/p>\n<hr \/>\n<p>Azure DevOps previously added capabilities for YAML based pipelines to the portion of the suite known as <a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/devops\/pipelines\/?nav=min\">Azure Pipelines<\/a>. Continuous Integration and Continuous Delivery strategies help teams to increase efficiency and drive quality, and YAML based pipelines layer additional capabilities, enabling developers to treat these CI\/CD Pipelines as code. There are great tools and resources for understanding how to <a href=\"https:\/\/devblogs.microsoft.com\/premier-developer\/converting-classic-azure-devops-pipelines-to-yaml\/\">Convert Classic Pipelines to YAML<\/a>, and there are more features being rapidly developed for Azure DevOps and YAML. One of these features is Multi-Stage Pipelines, which allows you to configure your pipelines to do CI, CD or both in your YAML pipeline.<\/p>\n<p>I experimented recently with Multi-Stage Pipelines, with a few specific questions in mind:<\/p>\n<ul>\n<li>Can I easily tell what stage of the pipeline my deployment is currently in?<\/li>\n<li>Can I redeploy an older build to a stage?<\/li>\n<li>Can I set approvals for different stages?<\/li>\n<\/ul>\n<p><strong>Note: <\/strong>Multi-stage Pipelines are currently available as a preview feature. See \u201c<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/project\/navigation\/preview-features?view=azure-devops&amp;tabs=new-account-enabled\">Enable Preview Features<\/a>\u201d for more information about enabling this experience.<\/p>\n<h3>Multi-Stage Pipeline YAML<\/h3>\n<p>As mentioned above, there are many options for creating your first YAML pipeline. The <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/yaml-schema?view=azure-devops&amp;tabs=schema%2Cparameter-schema\">YAML reference schema<\/a> was particularly helpful for configuring my first Multi-stage pipeline. <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/yaml-schema?view=azure-devops&amp;tabs=example%2Cparameter-schema#stage\">Stages<\/a> are a collection of related jobs, such as the \u201cBuild\u201d, \u201cTest\u201d, or \u201cDeploy.\u201d I used stages to build my application, and then target a deployment to my Dev environment, and then my QA environment.<\/p>\n<p>The first thing I wanted to see was whether I could <strong>easily tell what stage of the pipeline my deployment was currently in<\/strong>. There are two places this appears:<\/p>\n<p>In the \u201cRuns\u201d tab for my Pipeline, we can see that in the most recent run, my first two stages were successful, and my third stage is in the \u201cWaiting\u201d status.<\/p>\n<p><img decoding=\"async\" width=\"1430\" height=\"383\" class=\"wp-image-38870\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-62.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-62.png 1430w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-62-300x80.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-62-1024x274.png 1024w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-62-768x206.png 768w\" sizes=\"(max-width: 1430px) 100vw, 1430px\" \/><\/p>\n<p>If we drill into this specific run, on the summary page for this pipeline run, we can see more specifics about each stage. My build and deployment to Dev were complete, and my QA deployment is waiting for one check to be run.<\/p>\n<p><img decoding=\"async\" width=\"1517\" height=\"331\" class=\"wp-image-38871\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-63.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-63.png 1517w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-63-300x65.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-63-1024x223.png 1024w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-63-768x168.png 768w\" sizes=\"(max-width: 1517px) 100vw, 1517px\" \/><\/p>\n<p>Next, I wanted to see what the experience would be like to <strong>redeploy a previous build to an environment<\/strong>. My deployment to Dev was completed successfully, however I need to deploy yesterday\u2019s latest build to the dev environment. After navigating to the pipeline run that contains the build I want to deploy, in the \u201cDev Deployment\u201d Stage, after selecting the drop down arrow in the top right corner, I now see the option to \u201cRerun stage\u201d which allows me to redeploy the previous build to my Dev environment.<\/p>\n<p><img decoding=\"async\" width=\"2618\" height=\"725\" class=\"wp-image-38872\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-64.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-64.png 2618w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-64-300x83.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-64-1024x284.png 1024w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-64-768x213.png 768w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-64-1536x425.png 1536w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-64-2048x567.png 2048w\" sizes=\"(max-width: 2618px) 100vw, 2618px\" \/><\/p>\n<p>Lastly, I wanted to see if I could configure <strong>approvals before a deployment to a specific stage<\/strong>. Currently, manual approval checks are supported on environments. Using <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/yaml-schema?view=azure-devops&amp;tabs=example%2Cparameter-schema#environment\">Environments<\/a> in my YAML pipeline, I was able to add a manual approval check to ensure the deployment to the environment only happened when the designated user reviewed the changes being deployed. Note, this was not something I configured directly in the YAML file, however in the YAML file I added the environments keyword, and defined the approval in the Environment. This is described in more detail in this <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/process\/approvals?view=azure-devops&amp;tabs=check-pass#approvals\">Define Approvals and Checks<\/a> article. When the pipeline gets to my \u201cDev Deployment\u201d stage, we can see that it is in the \u201cWaiting\u201d status, and by the message displayed above, it is awaiting approval.<\/p>\n<p><img decoding=\"async\" width=\"1430\" height=\"405\" class=\"wp-image-38873\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-65.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-65.png 1430w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-65-300x85.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-65-1024x290.png 1024w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-65-768x218.png 768w\" sizes=\"(max-width: 1430px) 100vw, 1430px\" \/><\/p>\n<p><img decoding=\"async\" width=\"790\" height=\"488\" class=\"wp-image-38874\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-66.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-66.png 790w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-66-300x185.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-66-768x474.png 768w\" sizes=\"(max-width: 790px) 100vw, 790px\" \/><\/p>\n<p>After approving the deployment, not only does my stage proceed to run, but it also records the deployment of this build in the history of my Dev Environment, providing nice deployment history, and traceability for this environment.<\/p>\n<p><img decoding=\"async\" width=\"1430\" height=\"606\" class=\"wp-image-38875\" src=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-67.png\" srcset=\"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-67.png 1430w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-67-300x127.png 300w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-67-1024x434.png 1024w, https:\/\/devblogs.microsoft.com\/premier-developer\/wp-content\/uploads\/sites\/31\/2020\/03\/word-image-67-768x325.png 768w\" sizes=\"(max-width: 1430px) 100vw, 1430px\" \/><\/p>\n<p><strong>Note<\/strong>: Environments provide several additional capabilities not highlighted here, specifically serving as a collection of resources targeted by deployments including Kubernetes, Azure web apps, virtual machines, and databases. Additional information on environments can be found <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/process\/environments?view=azure-devops\">here<\/a>.<\/p>\n<p>YAML Pipelines enable you to store your pipeline as code, and Multi-stage YAML pipelines provide the ability to scale this to CI, CD, or the combination of the two. Don\u2019t hesitate to experiment with converting your CI\/CD pipelines to YAML!<\/p>\n","protected":false},"excerpt":{"rendered":"<p> YAML Pipelines enable you to store your pipeline as code, and Multi-stage YAML pipelines provide the ability to scale this to CI, CD, or the combination of the two.<\/p>\n","protected":false},"author":582,"featured_media":38877,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25,22,1],"tags":[2571,90,91],"class_list":["post-38869","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-devops","category-permierdev","tag-azure-devops","tag-cd","tag-ci"],"acf":[],"blog_post_summary":"<p> YAML Pipelines enable you to store your pipeline as code, and Multi-stage YAML pipelines provide the ability to scale this to CI, CD, or the combination of the two.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/38869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=38869"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/38869\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/38877"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=38869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=38869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=38869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}