1

我有一个成功部署到 Azure 的 Azure DevOps Build (yaml) 和 Release Pipeline (Classic)。

我正在尝试在多阶段 Yaml 管道中转换这两个单独的步骤。

在 Azure 应用服务部署任务 ( AzureRmWebAppDeployment@4) 中,我收到以下错误:

No package found with specified pattern: /home/vsts/work/1/a/*.zip

下面是我的多阶段 Yaml 管道

stages:
  - stage: Build
    jobs:
    - job: 'Build'
      pool:
        vmImage: 'windows-latest'

      variables:
        buildConfiguration: 'Release'

      steps:
      - task: DotNetCoreCLI@2
        displayName: Restore
        inputs:
          command: restore
          projects: '**/*.csproj'
          vstsFeed: 'dd55642d-8943-411f-8856-9714dd0da8af'

      - task: DotNetCoreCLI@2
        displayName: Build
        inputs:
          projects: '**/*.csproj'
          arguments: '--configuration $(buildConfiguration)'

      - task: DotNetCoreCLI@2
        displayName: Test
        inputs:
          command: test
          projects: '**/*[Tt]ests/*.csproj'
          arguments: '--configuration $(buildConfiguration)'

      - task: DotNetCoreCLI@2
        displayName: Publish
        inputs:
          command: publish
          publishWebProjects: false
          projects: '**/Tools.Client.Blazor.ServerApp.csproj'
          arguments: '--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)'

      - task: PublishSymbols@2
        displayName: 'Publish symbols path'
        inputs:
          SearchPattern: '**\bin\**\*.pdb'
          PublishSymbols: false
        continueOnError: true

      - task: CopyFiles@2
        displayName: 'Copy Files to: $(build.artifactstagingdirectory)\AzureDeploy'
        inputs:
          SourceFolder: AzureDeploy
          TargetFolder: '$(build.artifactstagingdirectory)\AzureDeploy'

      - task: PublishBuildArtifacts@1
        displayName: 'Publish Artifact: drop'
        inputs:
          PathtoPublish: '$(build.artifactstagingdirectory)'
        condition: succeededOrFailed()
        
  - stage: Systest
    jobs:
    - job: 'Systest'
      variables:       
        resourceGroupName: '$(appName)-rg-$(environment)'
        location: 'East US'
        appServiceName: '$(appName)-svc-$(environment)'
        appInsightsName: '$(appName)-ins-$(environment)'
        appServicePlanName: '$(appName)-asp-$(environment)'
        appName: 'tools'
        owner: 'Pod'
        environment: 'systest'    

      steps:
      - task: AzureResourceManagerTemplateDeployment@3
        displayName: 'ARM Template deployment: Resource Group scope'
        inputs:
          azureResourceManagerConnection: 'Dev/Test Connection'
          subscriptionId: ''
          resourceGroupName: '$(resourceGroupName)'
          location: '$(location)'
          csmFile: '$(System.DefaultWorkingDirectory)/AzureDeploy/Tools.azureDeploy.json'
          csmParametersFile: '$(System.DefaultWorkingDirectory)/AzureDeploy/Tools.azureDeploy.parameter.json'
          overrideParameters: '-appServiceName "$(appServiceName)" -appInsightsName "$(appInsightsName)" -appServicePlanName "$(appServicePlanName)" -owner "$(owner)" -environment "$(environment)" -location "$(location)"'

      - task: AzureRmWebAppDeployment@4
        displayName: 'Azure App Service Deploy: $(appServiceName)'
        inputs:
          ConnectionType: 'AzureRM'
          azureSubscription: ''
          appType: 'webApp'
          WebAppName: '$(appServiceName)'
          packageForLinux: '$(Build.ArtifactStagingDirectory)/*.zip'

任何帮助/建议将不胜感激。

4

2 回答 2

3

因为是2阶段第二阶段没有你在第一阶段发布的文件,你需要下载它。

您可以使用管道工件而​​不是构建工件。

管道工件提供了一种在管道中的阶段之间或不同管道之间共享文件的方法。它们通常是需要由另一个作业使用或部署的构建过程的输出。工件与生成它们的运行相关联,并在运行完成后保持可用。

发布(上传)当前运行的工件:

steps:
- publish: $(build.artifactstagingdirectory)
  artifact: drop

在第二阶段,您下载工件:

steps:
- download: current
  artifact: drop

您还可以通过构建工件DownloadBuildArtifacts@0任务下载来实现它。

于 2020-07-29T06:36:27.433 回答
-3

在发布期间,它不会像这样工作。而不是使用路径“/home/vsts/work/1/a/.zip ”,这个路径可以使用“$(System.DefaultWorkingDirectory)/_Releasepipelinename/drop/ .zip”

于 2020-07-29T05:55:40.633 回答