我试图在CI运行时自动创建一个请求注释。给定命令的输出写入一个文件(也可以只存储在环境变量中)。问题是,我通常会得到如下回应:将命令输出内插到GitHub REST请求中
curl -XPOST -d "{'body':'$RESULT'}" https://api.github.com/repo/name/issues/number/comment
{
"message": "Problems parsing JSON",
"documentation_url": "https://developer.github.com/v3/issues/comments/#create-a-comment"
}
这通常是由于unescpaed字符,如\n
,\t
,"
等
有没有简单的方法来实现这一目标的命令行或者用bq,sh,用jq或者Python?使用Octokit.rb
库可以直接使用,但我不想在构建环境中安装Ruby。