My new corporate overlords require that I have a SHA256 hash of each artifact on the customer portal. Of course, I can generate this myself or do it in build script or Makefile, but this feels like the sort of thing Jenkins would be able to do.
If your builds are running on Unix/Linux, from your Pipeline/Jenkinsfile, you can shell out to sha256sum
:
sha256sum = sh(returnStdout: true, script: "sha256sum '${fileName}'")
If your builds are running on Windows, you can shell out to Get-FileHash
(I haven't tested this):
sha256sum = powershell(
returnStdout: true,
script: "Get-FileHash -Algorithm sha256 -Path '${fileName}' | Select -ExpandProperty Hash"
)
You can use the jenkins utilty step: sha256
https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/
def hash = sha256 file: 'myfile.txt'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With