1 / 5

devops online training

DevOps Online Training at ITGuru will provide you the best knowledge on the tools, practices, and instruments that helps to enhance the capacity of applications & admin at high speed with live experts.<br>Learn about DevOps culture, processes, and tools, as well as practical techniques for infrastructure automation, continuous delivery, SRE, and more.<br>

cynixit
Télécharger la présentation

devops online training

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. If you have installed an Azure DevOps pipeline as your solution to a CI / CD pipeline, you've certainly run through situations where configuration values in builds and releases need to be controlled dynamically. Whether it's supplying a PowerShell script with a build version, passing dynamic parameters to construct tasks, or using strings through construct and release, you need variables. What are Variables of the Azure DevOps pipeline? Before we immerse ourselves in the specifics of variables, what are they and how do they help you build and automate efficient pipelines? We should know. Variables allow you to transfer bits of data into different parts of your pipelines. Variables are great for storing text and numbers which can change over the workflow of a pipeline. In a pipeline, you can set and read variables in scripts and YAML definitions almost everywhere, rather than hard-coding values. This article is only about YAML pipelines. We're not going to cover any information about classic legacy pipelines. You will also not learn how to work with variables via the Web UI, with a few minor exceptions. We will strictly stick to YAML. Variables are referenced and some specified during runtime (see user-defined variables). When a pipeline starts work, these variables are managed by different processes and their values are passed on to other parts of the system. This system provides a way to dynamically run pipeline work, without ever thinking about changing construct definitions and scripts. Don't worry if at this point you're not through the definition of variables. Variable environment It is first essential to cover variable environments in Azure pipeline before jumping into the variables themselves. Throughout the article you will see numerous references to that word. There are two areas inside a system where you can deal with variables, informally called environments. Within a YAML build definition called the pipeline environment, you can either work with variables, or within a script executed through a task called the script environment. The Green Pipeline It is called the pipeline environment, if you specify or read build variables from inside a YAML project specification. For example, you can see below the section of variables defined in a YAML build definition setting a variable named foo to bar. In this context, in the pipeline environment the variable is specified The Environmental Script You can also work with variables specified in the YAML description itself or in the scripts from within code. You can define and read variables within the YAML definition when you don't have an existing

  2. script already created as shown below. In this context, you will later learn the syntax on how to deal with those variables. Schemes: Additionally, you may remain within the script environment by inserting and executing this same syntax into a Bash script. That's almost the same general definition. Setup Variables in Azure DevOps Let us set up an AWS development system together with Terraform and Chef in one area in a few months. I found that I had to refactor my code in order to manage multiple regions like Multi-Region and AWS. I didn't want to duplicate code for different regions and for different climates. To manage the solution it will become a nightmare and have a terrible smell of code. Ee: Ee. I was new to Azure DevOps for CI / CD pipelines and I wanted to find a way to apply various sets of variables to the same code base so I poked around and found Variable Groups. 'This sounds very exciting! 'I thought and started to search through Microsoft's docs to know more. And here is the scoop on Classes of Variables. You may share group variables between pipelines. In a pipeline, you can create, or release variable groups "connect" to different stages. Groups Variables Follow the steps below to construct a Group of Variables. ●Select and enlarge Pipelines in the left row. ●Tap Library under the heading Pipelines. ●Click the Group Variable tab. ●In the field Variable Group Name, enter a name for the variable group. ●Using field Description to enter variable group information. ●To build a new community variable click on the Add button. ●Fill out the Name and Value variable.

  3. An example community variable us-east-1 for AWS. You will link our Variable Groups to an Azure DevOps Create and Release Pipeline for this tutorial. I'll give you two ways: As code in the Build Pipeline, with azure-pipeline.yml format. In Release Pipeline, with the Azure DevOps GUI. Install the Pipeline You need to configure a repository before we can connect the variable group to our construct. Can set up the repository in Azure DevOps or GitHub. I had used Azure DevOps for this tutorial. I have posted the code on GitHub but it's a fairly simple output to demonstrate how the Groups of Variables work. Lets you set up the construct with the following steps. ●Expand Pipelines in the left panel. ●Tap the button on the New pipeline. ●Associate the pipeline to a GitHub repo or Azure DevOps repo. ●Click the Run button.

  4. Our first build succeeds as planned, as we can see, but none of the variables have been echoed throughout the build. First, let the variable groups associated with the construct. Since the build uses the file azure- pipelines.yml, we will update the code to use the groups of variables. Check out Microsoft's YAML Schema Reference for more information on Azure Pipelines. Open azure-pipelines.yml in your editor. Then add the code snippet below to the file launch. Azure DevOps Variables-Variables: -- Batch: dev us-west-2 Save the file, and commit it. The build should execute and Azure DevOps output variables are stored in the dev us-west-2 variable group (see below). Now try on dev us-east-1. Let's take a step further into our variable groups and create two jobs: "Build us-east-1" and "Build us- west-2" You must fit the appropriate group of variables for this exercise to the job it is doing. Open the azure- pipelines.yml file in your favorite editor, and replace the GitHub branch 's text. Or just use the code below. After your changes have been saved, commit and press the code to run the build. Now you see two separate jobs, one for "build Virgina" and the other for each of our regions for "build Oregon" Open every task, and click the move "Display Variable Values." For each Variable Group the values echoed correspond to the job assigned in the code block above. See below for images.

  5. Now that we have learned how to associate Variable Groups by code to build pipelines, let 's move onto Releases. Release Pipeline You will build a Release Pipeline for both our areas, us-east-1 and us-west-2 for this portion of the tutorial. Using the steps below to build new Azure DevOps Update. Tap on Pipelines in the left hand row. Click The Releases button. Click the button on New Pipeline. For Stage 1 a new pane will open, prompting you to pick a template or begin with an Empty job. ●Click the Link to Empty Job. ●A new pane for the stage opens. Adjust the name of Stage to Release Us-East-1. ●To close the screen using the x in the upper right corner. Conclusion You should now have a firm understanding of variables in Azure Pipelines. You've learned about every concept in this article when it comes to variables. Get out there now, apply that information to your Azure DevOps pipelines and automate all the stuff. You can learn more through Azure DevOps online training.

More Related