管道中的AzureDevOps复制dist文件夹是否生成?为什么?

时间:2019-11-09 14:18:37

标签: azure-devops continuous-integration yaml

AzureDevOps->管道生成的工件中有一个dist文件夹的副本,该副本是/ dist文件夹,还有/ drop / dist文件夹。编辑:完整的azure-pipeline.yml文件

# Node.js with Angular
# Build a Node.js project that uses Angular.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

# Major modification referencing
# https://dev.to/thisdotmedia/continuously-integrating-angular-with-azure-devops-2k9l

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

# Build angular app area
- script: npm install
  displayName: 'npm install'

- script: npx ng build --prod
  displayName: 'npm build'

# Testing area
- script: npm install puppeteer --save-dev
  displayName: 'Installing puppeteer (Headless browser for testing)'

- script: npx ng test --watch=false --codeCoverage=true
  displayName: 'Running Tests'

- task: PublishTestResults@2
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/TEST-*.xml'
  displayName: 'Publish Test Results'

# Publishing items
#   deploy.psl (Powershell script to deploy)
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'deploy.ps1'
    ArtifactName: 'drop'
    publishLocation: 'Container'

#   Firebase.json
- task: PublishBuildArtifacts@1    
  displayName: 'Publish Artifact: Firebase.json'
  inputs:
    PathtoPublish: 'firebase.json'
    ArtifactName: 'drop'
    publishLocation: 'Container'

#   App
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'dist'
    ArtifactName: 'drop/dist'
    publishLocation: 'Container'
  displayName: 'Publish Artifacts'

#   Code Coverage Results
- task: PublishCodeCoverageResults@1
  condition: succeededOrFailed()
  inputs:
    codeCoverageTool: 'Cobertura'
    summaryFileLocation: '$(Build.SourcesDirectory)/coverage/ng-azure-devops/cobertura-coverage.xml'
  displayName: 'Publish Code Coverage Results'

- script: npx ng lint
  displayName: 'Code Analysis'

我尝试使用'drop'作为ArtifactName,这不会在任何地方产生重复的文件夹工件。我对为什么'drop / dist'会产生另一个'/ dist'伪像感到困惑

Image showing duplication of the dist folder

1 个答案:

答案 0 :(得分:1)

  

AzureDevOps管道中重复的dist文件夹会生成吗?为什么?

我可以重现此问题。

当我们将发布工件dist文件夹与ArtifactName: drop/dist一起使用时,Azure Devops将首先创建一个新文件夹drop ,然后发布工件{{ 1}}文件夹到该文件夹​​dist

您可以从构建日志中获得以下消息:

  

将“ / home / vsts / work / 1 / s / dist”上传到文件容器:   '#/ 3620698 / drop / dist'

但是,drop文件夹在默认情况下已经存在。当我们使用drop发布dist文件夹时,有两个ArtifactName: drop/dist文件夹,然后Azure devops将drop文件夹发布到这两个dist文件夹:< / p>

enter image description here

为了更清楚地理解此问题,您可以在预览功能禁用多级管道,然后您将获得输出:

enter image description here

很明显,这里有两个drop文件夹,这就是为什么在管道构建中获得Duplicate dist文件夹的原因。

因此,要解决此问题,我们可以将drop更改为ArtifactName: drop/dist

enter image description here

现在,重复的dist文件夹消失了。

希望这会有所帮助。

相关问题