【问题标题】:/bin/jq: Argument list too long/bin/jq: 参数列表太长
【发布时间】:2021-09-24 07:30:13
【问题描述】:

我正在使用 groovy 脚本并编写此行 Version_List=$(jq -r '.items[] .version' "${projectContent}")

${projectContent} 是 curl 命令的另一个变量 当我运行管道时,这是错误 /bin/jq: Argument list too long

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: json jenkins jq


【解决方案1】:

使用jq -Rs . <<< "${projectContent}" 将变量内容转换为JSON 字符串(您甚至可以直接使用curl,如下所示:curl … | jq -Rs),然后使用--slurpfileProcess Substitution 将该字符串导入jq 变量

jq --slurpfile projectContent <(
  jq -Rs . <<< "${projectContent}"
) '...' # your jq code here using variable $projectContent

别忘了添加-n 或输入文件。

【讨论】:

  • sh """ Version_List=\$( jq --slurpfile projectContent
  • @user16991581 进程替换语法是&lt;(,中间没有空格。
  • 不幸的是同样的错误,即使我把你的行复制粘贴
  • @user16991581 并非所有 shell 都支持进程替换。您在哪个 shell 中运行该命令?
  • /bin/bash shell,我不认为问题出在 shell
猜你喜欢
  • 2021-03-28
  • 2020-05-08
  • 2022-01-07
  • 2020-05-26
  • 2014-08-30
  • 2015-04-27
  • 2019-02-22
  • 2018-07-24
  • 1970-01-01
相关资源
最近更新 更多