是否有内置方法或插件可以让 Jenkins 为我的工件生成 SHA256 哈希?

kby*_*yrd 4 build sha256 jenkins jenkins-plugins

我的新公司霸主要求我在客户门户上拥有每个工件的 SHA256 哈希值。当然,我可以自己生成或在构建脚本或 Makefile 中生成它,但这感觉就像 Jenkins 能够做的那样。

jay*_*ren 8

如果您的构建在 Unix/Linux 上运行,从您的管道/Jenkinsfile,您可以 shell 到sha256sum

sha256sum = sh(returnStdout: true, script: "sha256sum '${fileName}'")
Run Code Online (Sandbox Code Playgroud)

如果您的构建在 Windows 上运行,您可以使用以下命令Get-FileHash(我还没有测试过):

sha256sum = powershell(
  returnStdout: true, 
  script: "Get-FileHash -Algorithm sha256 -Path '${fileName}' | Select -ExpandProperty Hash"
)
Run Code Online (Sandbox Code Playgroud)