2

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

PaulVrugt
  • 1,682
  • 2
  • 17
  • 40

2 Answers2

3

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.

enter image description here

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • i was really hoping to do this without having to unzip and rezip the package, but if you are sure this is the only way I'll accept the answer – PaulVrugt Apr 15 '20 at 07:40
  • This is the only way I can think of. Because the artifacts is a zip file generated by msbuild. You have to unzip it or you cannot copy in the vue artifacts. If the results for Build_web job is not a zip file. Then you donot have to unzip it. – Levi Lu-MSFT Apr 15 '20 at 08:01
  • Is it possible to have the build_web job not to generate a zip package (simply publish to file system) and generate the package to publish to azure later some other way? Or is there a diferent way to publish the result to azure without generating the package? – PaulVrugt Apr 15 '20 at 08:42
  • Hi @PaulVrugt you can try use msbuild arguments `/t:publish /p:outputpath=$(Build.ArtifactStagingDirectory)`. The results will be published to folder `$(Build.ArtifactStagingDirectory)\publish` and it is not zipped. – Levi Lu-MSFT Apr 15 '20 at 09:22
  • Yes I know, that's what I'm already doing before moving to Azure. But the deploy to azure requires a package. Is there a way to generate the package later manually, or to push a folder instead of a zip package to an azure web app. Because both options would solve my problem in a much more elegant way – PaulVrugt Apr 15 '20 at 10:33
  • 1
    You can specify a folder instead of a zip file to deploy in azure app service deployment task. Please check the package parameter for [azure app service deploy task](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops) – Levi Lu-MSFT Apr 15 '20 at 10:37
  • thank you, that seems to be the best solution to my issue – PaulVrugt Apr 15 '20 at 11:38
0

You can use PublishPipelineArtifact@1 to create artifacts for your projects and then in a separate job DownloadPipelineArtifact@2. By defining path you may compose your final artifact (if this mixing many projects is not more complicated than putting one inside another). And publish your artifact as build or pipeline artifact depending how you have roganized your release.

# Download an artifact named 'WebApp' to 'bin' in $(Build.SourcesDirectory)
- task: DownloadPipelineArtifact@2
  inputs:
    artifact: 'WebApp'
    path: $(Build.SourcesDirectory)/bin

Here you have more info about publishing and downloding artifacts.

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • Yes I know how to publish and download artifacts, that's not the issue. How do you suggest adding the files to the deployment package? The deployment package results in a zip file generated by msbuild. I hope you're not suggesting I manually unpack the generated zip, add the files and rezip it – PaulVrugt Apr 15 '20 at 06:08