简体   繁体   English

使用 Azure Devops yaml 管道部署到本地服务器

[英]Using Azure Devops yaml pipelines to deploy to on-prem servers

When using Azure DevOps pipelines, is it possible to deploy to on-prem servers using a yaml pipeline?使用 Azure DevOps 管道时,是否可以使用 yaml 管道部署到本地服务器?

I have deployed to on premise servers with a Release (classic) pipeline using deployment groups, and I have seen instructions on deploying to Azure infrastructure using yaml pipelines.我已经使用部署组部署到具有发布(经典)管道的本地服务器,并且我已经看到有关使用 yaml 管道部署到 Azure 基础设施的说明。

However I can't find any examples of how to deploy to on-prem servers using yaml pipelines - is this possible yet?但是,我找不到任何关于如何使用 yaml 管道部署到本地服务器的示例 - 这可能吗? If so are there any examples available of how to achieve this?如果是这样,是否有任何示例可以说明如何实现这一目标?

Yes you can.是的你可以。 In YAML pipelines you can use "Environments" as a replacement for deployment groups.在 YAML 管道中,您可以使用“环境”作为部署组的替代品。 They work in a similar way in that you install the agent on the target machine and then specify the environment in your Deployment Job它们的工作方式类似,您在目标机器上安装代理,然后在部署作业中指定环境

Create a new Environment with an appropriate name (eg Dev) then add a resource , you'll be able to add either a VM or a Kubernetes cluster.使用适当的名称(例如 Dev) 创建一个新环境,然后添加一个资源,您将能够添加 VM 或 Kubernetes 集群。 Assuming that you choose VM, then you will able to download a script which you can run an target machines to install the deployment agent.假设您选择 VM,那么您将能够下载一个脚本,您可以运行该脚本来运行目标机器来安装部署代理。 This script will install and register the agent in to the environment.此脚本将安装代理并将其注册到环境中。

Once you have the Agent registered in to the environment add a deployment job to your YAML将代理注册到环境中后,将部署作业添加到 YAML

- stage: DeployToDev
  displayName: Deploy to Dev
  jobs:
  - deployment: DeployWebSite
    displayName: Deploy web site to Dev
    environment: Dev
    strategy:
      runOnce:
        deploy:
          steps:
            - task: PowerShell@2
            inputs:
              targetType: 'inline'
              script: |
                Write-Host "Deploy my code"         

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM