【问题标题】:Correct way to use Publish Pileine Artifact , Download Pipeline Artifact and Deploy to Azure webapp使用 Publish Pipeline Artifact 、 Download Pipeline Artifact 和 Deploy to Azure webapp 的正确方法
【发布时间】:2021-03-13 18:06:25
【问题描述】:

首先,我正在构建一个概念证明来演示构建和部署(Azure Devops 中的 CI/CD0。 它是和 ASP.NET 4.8 WebApp。

使用 Download Build ArtifactsPublish Build ArtifactsDeploy Azure Webapp 等任务我没有任何问题。但我读到上述任务已被弃用,但只要我使用新的 Publish PipeLine Artifact Download Pipeline Artifact 然后部署 Azure Web 应用它不起作用。它发布并下载工件,但在部署 azure web 应用程序阶段它说找不到工件。事实是我不知道该填写什么。谷歌搜索我能找到的一切。 azure deploy 任务给了我这个错误:#[error]Error:

未找到具有指定模式的包:D:\a\1\drop*.*
检查 i

我在 Download Pipelineartifact 中看到了实际下载的工件:

Download artifact to: D:\a\1

实际的问题是,我应该用包填写什么 AzureWebApp@1 任务:'$(Pipeline.Workspace)/drop/.' (这是错误的,但我该如何纠正呢?)

非常感谢

约翰

这是我的 YAML 文件代码:

trigger:
- none
stages:

- stage: Build
  pool:
    vmImage: 'windows-latest'


  jobs:
  - job: Build


    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'

    steps:
    - task: NuGetToolInstaller@1

    - task: NuGetCommand@2
      inputs:
        restoreSolution: '$(solution)'

    - task: VSBuild@1
      inputs:
        solution: '$(solution)'
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'


    - task: PublishPipelineArtifact@1
      inputs:
        targetPath: '$(Pipeline.Workspace)'
        artifact: 'drop'
        publishLocation: 'pipeline'

- stage: Deploy
  pool:
    vmImage: 'windows-latest'

  jobs:
  - job: Deploy

    steps:

    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'current'
        artifactName: 'drop'
        targetPath: '$(Pipeline.Workspace)'


    - task: AzureWebApp@1
      inputs:
        azureSubscription: 'tofreewebapp'
        appType: 'webApp'
        appName: 'freewebappdave'
        package: '$(Pipeline.Workspace)/drop/*.*'
        deploymentMethod: 'auto'

【问题讨论】:

  • 你告诉它下载到$(Pipeline.Workspace),而不是$(Pipeline.Workspace)/drop。您可以添加 script 步骤并执行 PowerShell gci -rec 或类似操作以枚举所有文件及其路径。

标签: asp.net azure azure-devops yaml


【解决方案1】:
#[error]Error: No package found with specified pattern: D:\a\1\drop*.*

在 DownloadPipelineArtifact 任务中,您将工件下载到 Pipeline.Workspace 路径,但在 AzureWebApp 任务中,您指定的包路径是 $(Pipeline.Workspace)/drop/*.*。所以在放置文件夹中找不到包。

您可以将包路径更改为$(Pipeline.Workspace)

- task: AzureWebApp@1
      inputs:
        azureSubscription: 'tofreewebapp'
        appType: 'webApp'
        appName: 'freewebappdave'
        package: '$(Pipeline.Workspace)'
        deploymentMethod: 'auto'

【讨论】:

  • 谢谢!!起初没有工作同样的错误: D:\a\1\drop\
    Check 。但是……你确实帮了我!我按照您的建议运行它并收到上述错误,但是当我在下载任务中注释掉工件名称时,因此未指定 drop 它可以工作!
猜你喜欢
  • 2019-06-05
  • 2023-01-03
  • 1970-01-01
  • 1970-01-01
  • 2019-12-21
  • 2019-04-12
  • 1970-01-01
  • 2018-01-24
  • 2020-08-09
相关资源
最近更新 更多