0

我让Jobs在 YAML 管道中正常工作,但是当我将其更改为Deployment Job时,路径无法正常工作。

jobs:
  - job: InfrastructureAsCodeDeployment
    pool:
        name: Azure Pipelines
        vmImage: windows-2019
    steps:
    - task: "AzurePowerShell@2"
      displayName: 'Azure PowerShell script: Remove Keyvault'
      inputs:
        azureSubscription: 'Connection name'
        ScriptType: 'FilePath'
        ScriptPath: 'Powershell Scripts/IAC/kv-RemoveExistingSoftDeleted.ps1'
        ScriptArguments: '-vaultName $(keyVaultName) -location "$(location)"'
        azurePowerShellVersion: 'LatestVersion'
      continueOnError: true

在部署工作之后:-

  jobs:
  - deployment: InfrastructureAsCodeDeployment
    pool:
        name: Azure Pipelines
        vmImage: windows-2019
    environment: 'DEV'
        strategy:
          runOnce:
            deploy:
              steps:
              - task: "AzurePowerShell@2"
                displayName: 'Azure PowerShell script: Remove Keyvault'
                inputs:
                  azureSubscription: 'Connection name'
                  ScriptType: 'FilePath'
                  ScriptPath: 'Powershell Scripts/IAC/kv-RemoveExistingSoftDeleted.ps1'
                  ScriptArguments: '-vaultName $(keyVaultName) -location "$(location)"'
                  azurePowerShellVersion: 'LatestVersion'
                continueOnError: true

尝试将“System.DefaultWorkingDirectory”添加到部署,但仍然不起作用。

4

1 回答 1

0

开始时需要额外的步骤

steps:
- checkout: self 

看起来像这样

  jobs:
  - deployment: InfrastructureAsCodeDeployment
    pool:
        name: Azure Pipelines
        vmImage: windows-2019
    environment: 'DEV'
        strategy:
          runOnce:
            deploy:
              steps: 
              - checkout: self 
              - task: "AzurePowerShell@2"
                displayName: 'Azure PowerShell script: Remove Keyvault'
                inputs:
                  azureSubscription: 'Connection name'
                  ScriptType: 'FilePath'
                  ScriptPath: 'Powershell Scripts/IAC/kv-RemoveExistingSoftDeleted.ps1'
                  ScriptArguments: '-vaultName $(keyVaultName) -location "$(location)"'
                  azurePowerShellVersion: 'LatestVersion'
                continueOnError: true

不幸的是,文档没有说明这一点。但是与作业管道相比,我发现了这一点(部署管道没有可视化步骤。

在此处输入图像描述

于 2020-03-25T08:29:42.417 回答