2016-02-05 53 views
0

由於art.exe(artifactory CLI接口)在我的構建腳本中調用時會掛起,我正在從powershell 2.0中的page on the topic中重寫bash腳本。我使用這個代碼來生成校驗我:如何生成與artifactory相同的校驗和?

$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的產生。這不是'傳輸過程中的錯誤'錯誤,因爲我在本地生成了校驗和,而且我手動部署了好幾次。

如何以與artifactory(2.6.5)相同的方式生成校驗和,以便我發送我的校驗和時匹配,並且部署不會失敗?生成我的校驗和時,我做了什麼明顯錯誤?

謝謝!

回答

0

你必須使用

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