多阶段YAML管道不应用特定于环境的XML转换

问题描述 投票:1回答:1

我将在典型发布管道中执行的步骤转换为多阶段YAML管道。

问题在于,Web.config任务应用的AzureRmWebAppDeployment@4(XML)转换不再像以前那样工作。

此行为的记录方法是,首先将发行版配置用于转换,然后是特定于环境的配置。

从日志中,我看到应用了Web.Release.config,但是即使Web.TA.config(特定于环境的配置)存在并且阶段名称与配置名称匹配,也没有其他转换发生。

我有以下(简化的)YAML文件用于多阶段管道:

trigger: none

variables:
  azureSubscriptionProject: 'SubscriptionName'
  artifactDropDirectory: '$(Agent.BuildDirectory)/ProjectName'

stages:
- stage: Build
  jobs:
  - job: Build
    pool:
      vmImage: windows-2019
      demands:
      - msbuild
      - visualstudio
      - vstest
    variables:
      buildConfiguration: 'Release'
      buildPlatformSolutionLevel: 'Any CPU'
      buildPlatformProjectLevel: 'AnyCPU'
    steps:
    - template: azure-pipelines-ci-build-steps-template.yml
    - template: azure-pipelines-ci-build-publishing-steps-template.yml
- stage: TA
  dependsOn: Build
  jobs:
  - deployment: TA
    pool:
      vmImage: windows-2019
    environment: 'TA'
    timeoutInMinutes: 0
    strategy:
      runOnce:
        deploy:
          steps:
          # ...          
          - task: AzureRmWebAppDeployment@4
            displayName: 'Deploy ProjectName'
            inputs:
              azureSubscription: $(azureSubscriptionProject)
              webAppName: '$(AzureResourcesPrefix)-project-name'
              package: '$(artifactDropDirectory)/web-applications/ProjectName.zip'
              enableCustomDeployment: true
              removeAdditionalFilesFlag: true
              xmlTransformation: true
          # ...

此步骤/任务的日志摘录:

Start tranformation to 'D:\a\_temp\temp_web_package_39967480923393817\Content\D_C\a\1\s\src\ProjectName\obj\Release\Package\PackageTmp\Web.config'.
Source file: 'D:\a\_temp\temp_web_package_39967480923393817\Content\D_C\a\1\s\src\ProjectName\obj\Release\Package\PackageTmp\Web.config'.
Transform  file: 'D:\a\_temp\temp_web_package_39967480923393817\Content\D_C\a\1\s\src\ProjectName\obj\Release\Package\PackageTmp\Web.Release.config'.
Transformation task is using encoding 'System.Text.UTF8Encoding'. Change encoding in source file, or use the 'encoding' parameter if you want to change encoding.

有人也经历过这个问题吗?我是在做错什么,还是错误,甚至是设计使然?

我刚刚意识到有一个新的FileTransform task,但如果它以更简单的方式工作,我宁愿不使用它。

azure-devops azure-pipelines multistage-pipeline
1个回答
0
投票

设置变量Release.EnvironmentName解决了该问题,并且触发了特定于环境的配置转换。在阶段级别(如果所有作业共享相同的环境名称)和作业级别上,这是可能的。

示例:

# ...
- stage: TA
  dependsOn: Build
  variables:
    Release.EnvironmentName: TA
  jobs:
  - deployment: TA
    pool:
      vmImage: windows-2019
    environment: 'TA'
    # ...

MSFT on developercommunity.visualstudio.com提供的答案。

© www.soinside.com 2019 - 2024. All rights reserved.