【问题标题】:How can I generate the same checksum as artifactory?如何生成与工件相同的校验和?
【发布时间】:2016-02-05 14:57:11
【问题描述】:

由于art.exe(人工 CLI 接口)在我从构建脚本中调用它时挂起,因此我在 powershell 2.0 中从他们的page on the topic 重写 bash 脚本。我正在使用此代码生成我的校验和:

$sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider
$path = Resolve-Path "CatVideos.zip"
$bytes = [System.IO.File]::ReadAllBytes($path.Path)
$sha1.ComputeHash($bytes) | foreach { $hash = $hash + $_.ToString("X2") }

$wc=new-object System.Net.WebClient
$wc.Credentials= new-object System.Net.NetworkCredential("svnintegration","orange#5")
$wc.Headers.Add("X-Checksum-Deploy", "true")
$wc.Headers.Add("X-Checksum-Sha1", $hash)

问题是它在我的本地生成的校验和始终与工件生成的校验和不同。这不是“传输期间损坏”错误,因为我在本地生成校验和,并且我已经手动部署了几次。

如何以与 artifactory (2.6.5) 相同的方式生成校验和,以便我们的校验和在我发送时匹配并且部署不会失败?生成校验和时我做错了什么吗?

谢谢!

【问题讨论】:

    标签: powershell powershell-2.0 sha1 checksum artifactory


    【解决方案1】:

    你必须使用

    $wc.Headers.Add("X-Checksum-Sha1", $hash.ToLower())
    

    【讨论】:

      猜你喜欢
      • 2020-07-02
      • 2021-03-19
      • 2012-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      相关资源
      最近更新 更多