[英]What groovy cmd can I use for workstation cygwin and bash outside Jenkins?
I've got a CD pipeline running on Jenkins with some decryption code that uses base64
and gpg2
. 我在Jenkins上运行了一条CD管道,其中包含一些使用base64
和gpg2
解密代码。
I set up the pipeline so that the scripts grab and decrypt the correct passwords from git using the Jenkins shell command like this: 我设置了管道,以便脚本使用Jenkins shell命令从git抓取并解密正确的密码,如下所示:
def plainText = sh(script: """#!/bin/sh -e
echo "$encrypted" |
base64 -d -w 0 |
gpg2 --batch --decrypt --passphrase $pw """,
returnStdout: true
)
println("$key=$plaintext")
The pipeline works great and now I'm looking at writing a script for our dev workstations using maven-groovy-plugin
to do the same decryption locally to allow devs to run servers on workstations. 该管道运行良好,现在我正在考虑使用maven-groovy-plugin
为我们的开发人员工作站编写脚本,以在本地进行相同的解密,以允许开发人员在工作站上运行服务器。
My second requirement is that I can run my maven groovy plugin on Jenkins to set up the integration testing. 我的第二个要求是我可以在Jenkins上运行我的maven groovy插件来设置集成测试。
So I'm looking for a solution that I can use locally and on the build server. 因此,我正在寻找可在本地和构建服务器上使用的解决方案。 If necessary, I could make the script switch on the OS and execute something like this: 如有必要,我可以在操作系统上打开脚本并执行如下操作:
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()}"
}
but I'm not sure how to tweak the cmd
to execute with cygwin
. 但是我不确定如何调整cmd
以使用cygwin
执行。
I switched on the OS via the in-built JMX stuff and used either cygwin or linux: 我通过内置的JMX东西打开了操作系统,并使用cygwin或linux:
import java.lang.management.*
def os = ManagementFactory.operatingSystemMXBean
println """OPERATING SYSTEM:
\tarchitecture = $os.arch
\tname = $os.name
\tversion = $os.version
\tprocessors = $os.availableProcessors"""
def bash = os.name.contains("Win") ? "c:\\cygwin64\\bin\\bash" : "bash"
def cmd = [ bash, '-c',
"""echo "$encrypted" |
/usr/bin/base64 -d -w 0 |
/usr/bin/gpg2 --batch --decrypt --passphrase $encryptionKey """]
cmd.execute()...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.