【问题标题】:Azure Devops: Universal Publish uploads 0 mbAzure Devops:通用发布上传 0 mb
【发布时间】:2021-03-09 15:28:56
【问题描述】:

验证通用发布任务是否实际上传大于 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 工件版本的记录,我会全力以赴地寻求更好的实践)

【问题讨论】:

    标签: azure azure-devops azure-artifacts


    【解决方案1】:

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

    一种方法是使用预发布版本,例如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!"
          }
    

    【讨论】:

    • 预发布版本是个好点 - 我们一直在使用 -rc 后缀来表示一个包是候选发布,但我怀疑使用工件包促销(例如 @prerelease / @release) 是天蓝色希望你这样做的方式。所以这可能是一个不错的选择。但我可能会从 powershell 脚本检查中获得一些好处,tbh。
    猜你喜欢
    • 2020-01-18
    • 2021-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-26
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    相关资源
    最近更新 更多