简体   繁体   English

如何在 jenkins 中以有效的 json 格式转换 kubectl 命令?

[英]How to transform kubectl command in a valid json format in jenkins?

I am trying to parse in Jenkins the output of a kubectl command.我正在尝试在 Jenkins 中解析 kubectl 命令的 output。 My goal is to get how old a container is.我的目标是了解容器的年龄。 I am trying to run:我正在尝试运行:

myPods= sh(script:" kubectl get pods -o json", returnStdout: true)
test = readJSON text: myPods

Even though the output of echo myPods seems to be a valid json, I keep getting:即使echo myPods的 output 似乎是有效的 json,我仍然得到:

net.sf.json.JSONException: Invalid JSON String

Check out the myPods variable content, it might be some kubectl error logs.查看myPods变量内容,可能是一些 kubectl 错误日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM