且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在jenkins管道groovy脚本中使用json发出curl请求

更新时间:2023-02-24 14:53:14

'json'变量包含一个字符串,该字符串带有一个额外的尾随单引号(').

The 'json' variable contains a string that has an extra trailing single quote (').

在 -d'$ {json}' 我怀疑这会导致数据块中出现额外的(').数据块要求将JSON括在单引号中,因此请确保其中包括了这些引号.

When this is used in -d '${json}'" I suspect it will result in an extra (') in the data block. The data block will require the JSON be enclosed in single quotes so make certain those are included.

您可能不是必须要使用转义字符,否则您可能不是玩过Groovy的人(双关语意味十足的),它可以确保将正确的字符串传递给cURL命令.

Not being a Groovy person (pun intended) you may have to play with escaping characters it ensure that the correct string is passed to the cURL command.