我可以将什么 groovy cmd 用于工作站 cygwin 和 bash 在 Jenkins 之外?
What groovy cmd can I use for workstation cygwin and bash outside Jenkins?
我在 Jenkins 上有一个 CD 管道 运行ning,带有一些使用 base64
和 gpg2
的解密代码。
我设置了管道,以便脚本使用 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")
管道运行良好,现在我正在考虑使用 maven-groovy-plugin
为我们的开发工作站编写脚本以在本地执行相同的解密,以允许开发人员在工作站上使用 运行 服务器。
我的第二个要求是我可以 运行 我在 Jenkins 上的 maven groovy 插件来设置集成测试。
所以我正在寻找可以在本地和构建服务器上使用的解决方案。如有必要,我可以让脚本在 OS 上切换并执行如下操作:
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
执行。
我通过内置的 JMX 东西打开了 OS 并使用了 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()...
我在 Jenkins 上有一个 CD 管道 运行ning,带有一些使用 base64
和 gpg2
的解密代码。
我设置了管道,以便脚本使用 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")
管道运行良好,现在我正在考虑使用 maven-groovy-plugin
为我们的开发工作站编写脚本以在本地执行相同的解密,以允许开发人员在工作站上使用 运行 服务器。
我的第二个要求是我可以 运行 我在 Jenkins 上的 maven groovy 插件来设置集成测试。
所以我正在寻找可以在本地和构建服务器上使用的解决方案。如有必要,我可以让脚本在 OS 上切换并执行如下操作:
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
执行。
我通过内置的 JMX 东西打开了 OS 并使用了 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()...