Azure devops中的角项目CI给出错误“发布构建工件失败,并显示错误:”

时间:2019-07-18 07:33:54

标签: angular azure-devops continuous-integration azure-pipelines continuous-deployment

我正在GitHub中托管的一个项目中使用CI / CD。该项目分为两个子文件夹,其中一个包含在asp.net核心Web API项目中,另一个则是一个有角度的项目。我已经为asp.net核心项目成功构建了ci / cd,但是当我为角度项目构建ci / cd时,CI部分给出了错误

##[error]Publishing build artifacts failed with an error: Not found 
PathtoPublish: /home/vsts/work/1/s/dist

我的pipline yml脚本是:

    trigger:
    - master

    pool:
      vmImage: 'ubuntu-latest'

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

    - script: |
        pushd tritronFrontend
        npm install -g @angular/cli@7.3.8
        npm install
        ng build 
      displayName: 'npm install and build'

    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: 'dist'
      ArtifactName: 'dist'
      publishLocation: 'Container'

但是,当我在互联网上看到一些教程时,建议添加以下存档文件部分:

    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(Build.BinariesDirectory)'
        includeRootFolder: true
        archiveType: 'zip'
        archiveFile:'$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
        replaceExistingArchive: true

但这是触发的错误

    ##[error]Publishing build artifacts failed with an error: Not found 
    PathtoPublish: /home/vsts/work/1/s/dist

我已经尝试添加存档文件部分,但是没有用。

2 个答案:

答案 0 :(得分:0)

改为使用以下代码:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

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

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'
  workingDirectory: '$(Build.SourcesDirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.SourcesDirectory)/dist'
    ArtifactName: 'drop'
    publishLocation: 'Container'

答案 1 :(得分:0)

如果有人想在github上的任何特定文件夹中部署一个角度应用程序,那么在我的情况下,他必须推送这些特定角度的文件夹,我已经用下面的喜欢的脚本解决了我的问题:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

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

- script: |
    pushd tritronFrontend
    npm install -g @angular/cli@7.3.8
    npm install
    npm run build
    ng build --prod
  displayName: 'npm install and build'

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: 'tritronFrontend/dist'
    includeRootFolder: true
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true    
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'