【发布时间】: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