【发布时间】:2018-04-19 01:00:27
【问题描述】:
我想创建一个使用 JSON 对象作为其值的配置映射
JSON 对象看起来像这样,(variable name = manifestJSON)
{
"appRepoVersionsMap": {
"repoA": "1.0.0.131",
"repoB": "1.0.0.7393"
},
"deployerVersion": "49",
"openshiftConfigCommitId": "o76to87y"
}
然后我想创建一个配置映射,它接受这个 JSON 对象并将其添加为配置映射的值。
我试图让它工作的命令是
def osCmd = "create configmap manifest-config" +
" --from-literal=manifest.os_config_branch=${envVars.OS_CONFIG_BRANCH}" +
" --from-literal=manifest.os_server=${envVars.OPENSHIFT_SERVER_URL}"
" --from-literal=manifest.os_manifest=${manifestJSON}"
os.call(osCmd)
OpenShift 客户端给出以下错误:
10:23:37 error: cannot add key manifest.os_manifest, another key by that name already exists: map[manifest.os_config_branch:deployment-orchestrator manifest.os_server:<snipped>, manifest.os_manifest:appRepoVersionsMap:repoA:1.0.0.131 ].
所以 groovy 或 OpenShift 看到 JSON 对象中的 JSON 对象并且无法处理它。
我试图避免使用--from-file,因为我必须先写入磁盘然后运行命令,而且我担心这会在 Jenkins 环境中导致对多个项目进行多次部署的问题。
【问题讨论】: