使用devops多阶段管道部署时出错

时间:2019-07-24 22:46:49

标签: azure-devops yaml devops

我正在使用azure devops多阶段管道,并且具有以下YAML文件。我可以创建一个构建,然后发布该构建构件以删除。尝试部署时,出现以下错误。

我已经尝试了很多事情,但是我希望我的部署位于同一个管道中,因为我知道您可以将其添加到发布管道中。我想念什么吗?

stages:
- stage: Build
jobs:
- job: Build
  pool:
    name: Hosted Windows 2019 with VS2019
    demands: azureps

  steps:

# Restore
  - task: DotNetCoreCLI@2
    displayName: Restore
    inputs:
      command: restore
      projects: '**/*.csproj'
      feedsToUse: select
      vstsFeed : myfeed
      includeNuGetOrg : true

# Build
  - task: DotNetCoreCLI@2
    displayName: Build
    inputs:
      command: build
      projects: '**/*.csproj'
      arguments: '--configuration Release' 

# Publish
  - task: DotNetCoreCLI@2
    displayName: Publish
    inputs:
      command: publish
      publishWebProjects: True
      arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
      zipAfterPublish: True

# Publish Artifact
  - task: PublishBuildArtifacts@1

- stage: Dev
  jobs:
  # track deployments on the environment
  - deployment: DeployWeb
   pool:
     vmImage: 'ubuntu-latest'
     # creates an environment if it doesn’t exist
   environment: 'my-dev'
   strategy:
     # default deployment strategy
     runOnce:
      deploy:
        steps:
         - task: DownloadBuildArtifacts@0
           inputs:
             buildType: 'current'
             downloadType: 'single'
             artifactName: 'drop'
             downloadPath: '$(build.ArtifactStagingDirectory)'

         - task: AzureWebApp@1
           displayName: Azure Web App Deploy
           inputs:
             appType: 'webapp'
             azureSubscription: '213456123'
             appName: mytestapp
         package:$(System.DefaultWorkingDirectory)/**/*.zip

错误,我收到enter image description here

2 个答案:

答案 0 :(得分:1)

工件已下载到工件文件夹 $(build.ArtifactStagingDirectory),因此包路径可能为:package:$(build.ArtifactStagingDirectory)/**/*.zip

答案 1 :(得分:0)

就我而言,我只是在实现后将 DownloadBuildArtifacts @ 0 任务中的工件下载路径复制,并将其粘贴到 AzureWebApp @ 1 任务的包属性。

是的,这需要我运行一次失败才能找到下载工件的确切路径。只能简单地运行 DownloadBuildArtifacts @ 0 任务,以便您可以找到工件的精确下载路径。