【问题标题】:Error deploying with devops multi staging pipelines使用 devops 多阶段管道部署时出错
【发布时间】:2019-07-24 22:46:49
【问题描述】:

我正在使用 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

错误我收到

【问题讨论】:

  • 在发布管道中有一个下载工件任务 - 将 zip 拖放到的日志输出,即Downloading drop/ReleaseFiles.zip to C:\agents\release\1\_work\r9\a\Build\drop\\ReleaseFiles.zip,这将在部署阶段确认位置正确?
  • 你是怎么得到这个错误的?您的 yaml 中没有 Drop/DepartmentAPI.zip 路径。

标签: azure-devops yaml devops


【解决方案1】:

工件已经下载到工件文件夹$(build.ArtifactStagingDirectory),所以包路径可以是:package:$(build.ArtifactStagingDirectory)/**/*.zip

【讨论】:

  • 问题是下载神器任务下载到路径:Downloaded drop/DepartmentAPI.zip to /home/vsts/work/1/a/drop/DepartmentAPI.zip 我需要下载到work/1/s文件夹不行/1/a /home/vsts/work/1/s/Drop
  • @johnny0013 你的意思是在发布管道中使用下载工件任务吗?
  • 我正在使用 devops 多级管道。在上面 YAML 中看到的我的开发阶段,我首先下载工件,是的,下载工件任务。但是AzureWebApp@1任务正在寻找/home/vsts/work/1/s/Drop中的文件但是已经下载到/home/vsts/work/1/a/Drop
  • @johnny0013 改用downloadPath: '$(System.DefaultWorkingDirectory)'
【解决方案2】:

在我的例子中,我只是从 DownloadBuildArtifacts@0 任务中复制了工件下载路径在其实施之后 并将其粘贴到 AzureWebApp@1 任务的包属性。

是的,它要求我运行一次失败,以便我可以找到下载工件的确切路径。只需运行 DownloadBuildArtifacts@0 任务,您就可以找到准确工件的下载路径。

【讨论】:

    猜你喜欢
    • 2020-11-23
    • 1970-01-01
    • 2022-12-19
    • 1970-01-01
    • 2020-09-22
    • 2021-03-25
    • 2020-04-07
    • 2020-12-03
    • 2022-06-28
    相关资源
    最近更新 更多