Azure Devops:通用发布上传 0 mb

Azure Devops: Universal Publish uploads 0 mb

验证通用发布任务实际上传大于 0mb 的工件而不是空工件的最佳方法是什么?

例如,我有一项工作是从之前的工作中下载管道工件,然后检查各种条件,然后将之前的工作的工件作为通用包上传。由于我的失误,工件被下载到工作区,但发布是从工件暂存目录中提取的。当我不那么累时,我发现了这一点,但是由于您不能用已经设置的版本覆盖任何以前发布的包,现在我必须清理一些混乱。我想在未来避免这种痛苦。

- job: "releasepublish"
    dependsOn: 
      - "cicd"
    condition: startsWith(variables['build.sourceBranch'], 'refs/heads/release')
    variables: 
      outputVersion: $[ dependencies.cicd.outputs['windows.VersionNumber.appVersion'] ] 
    steps:
      - task: DownloadPipelineArtifact@2
        inputs:
          buildType: 'current'
          targetPath: '$(Pipeline.Workspace)'
      - task: UniversalPackages@0
        inputs:
          command: 'publish'
          publishDirectory: '$(Build.ArtifactStagingDirectory)'
          feedsToUsePublish: 'internal'
          vstsFeedPublish: '...'
          vstsFeedPackagePublish: '$(Build.SourceBranchName)'
          versionOption: 'custom'
          versionPublish: '$(outputVersion)'
          packagePublishDescription: 'master branch release $(outputVersion) for $(Build.SourceBranchName)'

世界上最悲伤的成功信息:

2021-03-09T14:49:27.2499973Z {"@t":"2021-03-09T14:49:26.6123086Z","@m":"\n
Content upload statistics:\n
Total Content: 0.0 MB\n
Physical Content Uploaded: 0.0 MB\n
Logical Content Uploaded: 0.0 MB\n
Compression Saved: 0.0 MB\nDeduplication Saved: 0.0 MB\n
Number of Chunks Uploaded: 0\n
Total Number of Chunks: 1\n
","@i":"13d73b85","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2021-03-09 14:49:26.612Z"}
...
2021-03-09T14:49:27.2504559Z {"@t":"2021-03-09T14:49:27.2346667Z","@m":"Success","@i":"1d9af52f","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2021-03-09 14:49:27.234Z"}

(切线地,如果您有处理节点应用程序包版本和 azure 工件版本的记录,我会全力以赴进行更好的练习)

What's the best way to verify that a universal publish task actually uploads an artifact > 0mb, instead of an empty artifact?

一种方法是使用预发布版本,例如1.0.0-alpha。确认预发布版神器内容后,再发布正式版神器,如1.0.0.

一个更麻烦的解决方案是在发布工件之前检查目录是否为空。

这是一个使用 PowerShell 的示例:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      $directoryInfo = Get-ChildItem $(Build.ArtifactStagingDirectory) | Measure-Object
      if ($directoryInfo.count -eq 0) 
      {
        throw "EMPTY!"
      }