我们需要在此Jenkinsfile上仅返回来自k8s应用程序的修订号作为选项,但是该命令返回整个输出,并且我在该命令上执行的所有正则表达式和转义符均未使用。这是代码:
choiceType: 'PT_SINGLE_SELECT',description: 'Revision of the application on kubernetes',name: 'revision',omitvalueField: false,randomName: 'choice-parameter-5633384460832177',referencedParameters: 'namespaces,deployment',script: [
$class: 'GroovyScript',script: [
classpath: [],sandbox: true,script: """
if (namespaces.equals("Select")){
return["Nothing to do - Select your deployment"]
} else {
def revResult = null
def kubecmd0 = "kubectl rollout history deploy --kubeconfig=${kubefilePrd} -n " + namespaces + " " + deployment + " "
def kubecmd1 = kubecmd0.execute().in.text.split().toList()
return kubecmd1
}
"""
]
在詹金斯的工作上:
是否有任何函数或魔术正则表达式可以解决此问题?