azure - 跳过暂存和生产

标签 azure azure-devops azure-pipelines

整个管道已成功运行,但为什么跳过了暂存和生产? 我已完成 Azure 管道中的所有步骤,但尚未完成暂存和生产。我想知道为什么那些会跳过

enter image description here azure 管道.yml

  branches:
    include:
    - master
pool:
  name: CharanAgentPool
variables:
- name: buildConfiguration
  value: Release
stages:
- stage: Build
  displayName: ApplicationBuild
  jobs:
  - job: Build
    variables:
    - name: continueOnError
      value: false
    steps:
    - task: DotNetCoreCLI@2
      inputs:
        command: restore
        projects: '**/*.csproj'
    - task: VSBuild@1
      inputs:
        solution: '**\*.sln'
        msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"
        configuration: release
        clean: true
        restoreNugetPackages: true
    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: $(Build.ArtifactStagingDirectory)
        ArtifactName: drop
        publishLocation: Container
- stage: Test
  displayName: UnitTest
  jobs:
  - job: Test
    steps:
    - task: VSTest@2
      inputs:
        testSelector: testAssemblies
        testAssemblyVer2: >
          **\*test*.dll

          !**\*TestAdapter.dll

          !**\obj\**
        searchFolder: $(System.DefaultWorkingDirectory)
- stage: SonarQube
  displayName: StaticCodeAnalysis
  jobs:
  - job: SonarQube
    steps:
    - task: CmdLine@2
      inputs:
        script: echo "code analysis"

- stage: deploy_dev
  displayName: ApplicationDeplo
  jobs:
  - job: dev
    steps:
    - task: DownloadBuildArtifacts@0
      inputs:
        buildType: current
        downloadType: single
        artifactName: drop
        downloadPath: $(System.DefaultWorkingDirectory)
    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: AzureRM
        azureSubscription: '$(connectedservicename)'
        appType: webApp
        WebAppName: '$(app_name)'
        packageForLinux: $(System.DefaultWorkingDirectory)/drop/*.zip
- stage: functionaltest_dev
  displayName: FunctionalTest
  jobs:
  - job: FunctionalTesting
    steps:
    - task: CmdLine@2
      inputs:
        script: echo "function testing"
- stage: deploy_staging
  displayName: staging
  jobs:
  - job: staging
    condition: and(succeeded(), eq(variables['deploy_staging'], 'yes'))
    steps:
    - task: DownloadBuildArtifacts@0
      inputs:
        buildType: current
        downloadType: single
        artifactName: drop
        downloadPath: $(System.DefaultWorkingDirectory)
    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: AzureRM
        azureSubscription: '$(connectedservicename)'
        appType: webApp
        WebAppName: $(staging_app)
        packageForLinux: $(System.DefaultWorkingDirectory)/drop/*.zip
- stage: functionaltest_staging
  displayName: FunctionalTestStaging
  jobs:
  - job: FunctionalTesting
    steps:
    - task: CmdLine@2
      inputs:
        script: echo "function testing"
- stage: deploy_prod
  displayName: DeployToProd
  jobs:
  - job: prod
    condition: and(succeeded(), eq(variables['deploy_prod'], 'yes'))
    steps:
    - task: DownloadBuildArtifacts@0
      inputs:
        buildType: current
        downloadType: single
        artifactName: drop
        downloadPath: $(System.DefaultWorkingDirectory)
    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: AzureRM
        azureSubscription: '$(connectedservicename)'
        appType: webApp
        WebAppName: $(prod_app)
        packageForLinux: $(System.DefaultWorkingDirectory)/drop/*.zip
- stage: functionaltest_prod
  displayName: FunctionalTestingProd
  jobs:
  - job: FunctionalTesting
    steps:
    - task: CmdLine@2
      inputs:
        script: echo "function testing"

整个管道已成功运行,但为什么跳过了 staging 和 prod?

最佳答案

- job: staging
  condition: and(succeeded(), eq(variables['deploy_staging'], 'yes'))

这 block 管道控制作业何时运行。您设置的条件会检查之前的步骤是否成功结束以及变量 deploy_staging 是否设置为 yes。

您从未将变量设置为 yes,因此该作业不会运行。

关于azure - 跳过暂存和生产,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71817448/

相关文章:

c# - Azure Service Fabric 无法使用 ASP.NET Core 在 VSTS 上执行 CI

azure - 部署到云时无法加载文件或程序集“Microsoft.WindowsAzure.ServiceRuntime,版本=1.8.0.0”

powershell - 无法找到 Azure 流量管理器 PowerShell Cmdlet

azure-devops - 探索托管代理上的文件系统

angular - 在 Visual Studio Team Services 中发布 Angular 4 项目时出错

azure - 通过 YML 按计划运行特定阶段

c# - VSTS 无法加载源 401 的服务索引

azure - 如何从 terraform 获取 Azure Security Insights 对象 ID?

sql - 创建在 Azure Databricks 中传递日期以进行查询的小部件

azure-devops - 使用 AppCmd "IIS Web App Manage"在 "Not enough storage is available to process this command."步骤上进行 VSTS 发布错误