base64
和
gpg2
.
def plainText = sh(script: """#!/bin/sh -e
echo "$encrypted" |
base64 -d -w 0 |
gpg2 --batch --decrypt --passphrase $pw """,
returnStdout: true
)
println("$key=$plaintext")
管道工作得很好,现在我正在考虑为我们的开发人员工作站编写一个脚本,使用
maven-groovy-plugin
在本地执行相同的解密,以允许开发人员在工作站上运行服务器。
所以我在寻找一个可以在本地和构建服务器上使用的解决方案。如果需要,我可以在操作系统上切换脚本并执行如下操作:
def cmd = [ 'sh', '-c',
"""echo "$encrypted" |
base64 -d -w 0 |
gpg2 --batch --decrypt --passphrase $encryptionKey """]
cmd.execute().with {
def output = new StringWriter()
def error = new StringWriter()
//wait for process ended and catch stderr and stdout.
it.waitForProcessOutput(output, error)
println "error=$error"
println "output=$output"
println "code=${it.exitValue()}"
}
但我不知道如何调整
cmd
cygwin