【问题标题】:Really looking for a example/use case, when to use stages in Azure Devops [duplicate]真正寻找示例/用例,何时在 Azure Devops 中使用阶段 [重复]
【发布时间】:2021-04-18 11:49:36
【问题描述】:

当 Azure DevOps 中需要阶段时,我真的很困惑。

考虑下面的这段代码,它可以工作、构建和部署,但它是一项包含多项任务的大型隐式工作。 我本可以创建一个包含多个作业的构建和部署阶段,但是有没有人有一个示例/用例什么时候有用?

  # ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

- task: DownloadBuildArtifacts@0
  inputs:
    buildType: 'current'
    downloadType: 'single'
    artifactName: 'drop'
    downloadPath: '$(System.ArtifactsDirectory)'

- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    appType: 'webApp'
    WebAppName: 
    packageForLinux: '$(System.ArtifactsDirectory)/drop/*.zip' 

【问题讨论】:

  • 我对你在问什么感到有点困惑。您是在问如果可以将阶段作为一项大工作,为什么还要使用阶段?我想需要考虑的是“dependsOn”。例如,如果您有“构建”和“部署”阶段,那么您的“部署”阶段将“依赖”“构建”阶段才能成功。
  • 嗨 OH.IO.Dev 是的,这正是我要问的,这是一个很好的例子,除此之外还有其他原因吗?非常感谢您的回复
  • 您是从查看文档开始的吗?它解释了用例并提供了示例。

标签: azure-devops yaml


【解决方案1】:

将我们的发布管道拆分为每个部署环境的单独阶段对我的团队很有帮助。当我们部署到 AWS 时,我们还为每个区域采用了单独的阶段。这允许我们同时在 us-east-2 和 us-east-1 中部署到我们的开发环境。您可以使用这种方法来实现高可用性和/或灾难恢复。

这是一个包含更多信息的链接:https://docs.microsoft.com/en-us/azure/devops/pipelines/release/define-multistage-release-process?view=azure-devops

这是该类型的简单示例图像 Release pipeline.

【讨论】:

    猜你喜欢
    • 2019-09-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    • 2013-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多