groovy 当使用curl作为jenkins管道的post请求对其进行解析时,无法转义空星号“*”

fcg9iug3  于 2022-11-01  发布在  Jenkins
关注(0)|答案(1)|浏览(299)

我有一部分XML配置文件被另一个java应用程序读取。这个值被传递用于过滤,groovy通过管道将其放入文件中。问题是当groovy试图解析双引号中的星号时,我找不到方法来转义它。
我尝试了"*\”以及许多使用单引号和双引号的变体,并将其表示为var,然后将其作为值引入,但没有效果
","reason":"Malformed request body","details":[{"field":null,"messages":["JSON parse error: Unexpected character ('' (code 42)): was expecting comma to separate Object entries; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected character ('*' (code 42))
〈〈执行后我们看到的:〉〉〉〉〉
请更正并重新发布。
","reason":"Malformed request body","details":[{"field":null,"messages":["JSON parse error: Unexpected character ('' (code 42)): was expecting comma to separate Object entries; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected character ('*' (code 42))

qyuhtwio

qyuhtwio1#

您可以尝试以下操作吗?

script {
        def data = '{"addOrUpdate": [{"name": "pod1","properties": {"DOMAIN": "<domain type=\"*\" </"}}]}'
        writeFile(file: 'data.json', text: data)
        sh "cat data.json"
        sh "curl -v --request POST http://localhost:8080 --header 'X-Corellation-Id: abcd' --header 'Content-Type: application/json' -d @data.json"           
   }

相关问题