将几个管道作业的结果合并到azure Web应用程序包中 [英] Combine results of several pipeline jobs into azure web app package

查看:42
本文介绍了将几个管道作业的结果合并到azure Web应用程序包中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将我们的产品转移到Azure Web应用程序中.我们有一个广泛的现有管道,其中包含多个并行作业.这些工作之一是编译一个asp.net Web应用程序.其他一些人则编译了一个vue.js网站.当前,Web应用程序和vue项目的结果使用Powershell脚本在单独的阶段中组合在一起.

现在,我可以转换Web应用程序的发布步骤,以生成用于Azure的部署程序包.但是,将Vue输出也添加到此程序包中的最佳方法是什么,以便我可以正确地部署它以使azure不丢失并行作业?我不能将is输出文件包含在我的项目中,因为它们不在Web应用程序构建作业中

解决方案

如@Krzysztof所述,您可以使用发布构建工件任务将Web应用程序和vue项目的构建结果上载到azure devops服务器.然后,您可以添加新任务以下载工件.

请在yaml中检查以下简单示例.

为了合并构建结果,可以使用

We're in the process of moving our product to an azure web app. We have an extensive existing pipeline containing multiple parallel jobs. One of these jobs compiles a asp.net web application. Some others compile a vue.js website. Currently, the results of the web application and the vue projects are combined in a separate stage, using a powershell script.

Now I can convert the publish step of the web application to generate a deployment package for azure. But what is the best way of also adding the vue outputs into this package so I can deploy it to azure correctly, without losing the parallel jobs? I cannot include the is output files in my project, because they don't exist within the web application build job

解决方案

You can use publish build artifact task to upload the build results of the web application and vue projects to azure devops server as @Krzysztof mentioned. And you can add a new job to download the artifacts.

Please check below simple example in yaml.

In order to combine the build results, you can use extract file task to extract the zipped artifacts and published the unpacked artifacts in Build_web job. And in the Combine job you can use copy file task to copy the results of vue artifacts to the web artifacts folder. And then you can use archive file task to pack the artifacts which now contains the results of web and vue application.

Combine job should dependsOn Build_web and Build_vue jobs

  jobs:
  - job: Build_Web
    pool: 
      vmImage: "windows-latest"
    steps:
    - task: ExtractFiles@1
      inputs:
        archiveFilePatterns: '*.zip'
        destinationFolder: '$(Build.ArtifactStagingDirectory)\unzip'
    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)\unzip'
        artifactName: webapp

  - job: Build_Vue
    pool:  
      vmImage: "windows-latest"
    steps:

    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: 'path to the build results'
        artifactName: vueapp

  - job: Combine
    dependsOn:
    - Build_Web
    - Build_Vue
    pool:  
      vmImage: "windows-latest"
      steps:
      - task: DownloadBuildArtifacts@0
        inputs:
          buildType: 'current'
          artifactName: webapp
          downloadPath: "$(System.ArtifactsDirectory)"

      - task: DownloadBuildArtifacts@0
        inputs:
          buildType: 'current'
          artifactName: vueapp
          downloadPath: "$(System.ArtifactsDirectory)"

      - task: CopyFiles@2
        inputs:
          SourceFolder: '$(System.ArtifactsDirectory)\vueapp'
          TargetFolder: 'path to web application result folder'  #eg. $(System.ArtifactsDirectory)\webapp\Content\d_C\a\1\s\AboutSite\AboutSite\obj\Release\netcoreapp2.0\PubTmp\Out\

      - task: ArchiveFiles@2
        inputs:
          rootFolderOrFile: $(System.ArtifactsDirectory)\webapp
          archiveType: 'zip'
          archiveFile: '$(Build.ArtifactStagingDirectory)/webapplication.zip' 

Above example only shows a general idea. You can aslo move the ExtractFile task to Combine job. In either way, you will have to use extract file, copy file and archive file task.

For TargetFolder parameter in copy file task, you can check the download build artifacts log for webapp artifact to get the full path. For example as below screenshot shows.

这篇关于将几个管道作业的结果合并到azure Web应用程序包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆