如何通过jq使用变量更新键值?

时间:2019-08-31 13:32:02

标签: json unix jq

我是jq的新手。每当管道运行时,我想替换config.json中的键值。

我的config.json看起来像这样

{
   "service": "test-service",
   "imageTag": "v1"
}

我尝试了以下命令。

export imageTag="v2" // This comes from CodeBuild stage but not relevant here     
jq '.Parameters.imageTag = ${imageTag}' config.json | sponge config.json

我遇到以下错误。

jq: error: syntax error, unexpected '{', expecting IDENT or __loc__ (Unix shell quoting issues?) at <top-level>, line 1:
.Parameters.imageTag = ${imageTag}                        
jq: 1 compile error

有人可以帮忙吗?

0 个答案:

没有答案
相关问题