我想在给定artifactory url的情况下从artifactory中读取校验和,并将其附加到一个属性中。我试图寻找示例,但人们对校验和值进行了硬编码,如下所示。如果我硬编码值,当我有新的工件时,我将不得不更新它。我不想那样做。如果有任何方法可以从artifactory获取这个值,请让我知道。我在我的厨师代码中使用digest计算校验和。我将比较来自artifactory的校验和和我在配方中计算的校验和。
source 'http://www.example.com/tempfiles/testfile'
mode '0755'
checksum '3a7dac00b1' # A SHA256 (or portion thereof) of the file.
end
To compare the computed checksum with the local checksum, I have seen people hardcoding local checksum value. Instead I want to read it from artifactory through chef. ex:
```computed_checksum = Digest::SHA2.file(temp.path).hexdigest Artifactory_checksum = Read from artifactory ? 如果Artifactory_checksum != computed_chceksum抛出错误.‘
发布于 2019-09-28 00:56:47
require 'open-uri'
require 'tempfile'
jar_file = 'https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.17/mysql-connector-java-8.0.17.jar'
temp = Tempfile.new
temp << open(jar_file).read
temp.flush
actual_sha1 = Digest::SHA1.file(temp.path).hexdigest
sha1_file = 'https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.17/mysql-connector-java-8.0.17.jar.sha1'
expected_sha1 = open(sha1_file).read.strip
p actual_sha1 == expected_sha1https://stackoverflow.com/questions/58137815
复制相似问题