-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
the writeJSON step currently only allows for serialization of a variable object (map, list etc) to file, but for certain operations (such as executing an adhoc curl), it would be nice if you could serialize to a string and then use that as part of the call.
For example:
sh (script: "curl -s http://localhost/rpc -d '{ \"field1\": 123 }' -H 'Content-Type: application/json'")
Could be re-written as:
def bodyMap = readJSON text: '{}' bodyMap.field1 = 123 def jsonStr = writeJSON json: bodyMap sh (script: "curl -s http://localhost/rpc -d '${jsonStr}' -H 'Content-Type: application/json'")
Granted you could just serialize to file and then pass that file to the curl command.
- is duplicated by
-
JENKINS-63720 add returnText option to writeJSON
-
- Closed
-
[JENKINS-48148] writeJson step to serialize to string variable
Description |
Original:
the writeJSON step currently only allows for serialization of a variable object (map, list etc) to file, but for certain operations (such as executing an adhoc curl), it would be nice if you could serialize to a string and then use that as part of the call. For example: {code:java} sh (script: "curl -s http://localhost/rpc -d '{ \"field1\": 123 }' -H 'Content-Type: application/json'"){code} Could be re-written as: {code:java} def bodyMap = readJSON text: '{}' bodyMap.field1 = 123 def jsonStr = writeJSON json: bodyMap sh (script: "curl -s http://localhost/rpc -d '${jsonStr}' -H 'Content-Type: application/json'){code} Granted you could just serialize to file and then pass that file to the curl command. |
New:
the writeJSON step currently only allows for serialization of a variable object (map, list etc) to file, but for certain operations (such as executing an adhoc curl), it would be nice if you could serialize to a string and then use that as part of the call. For example: {code:java} sh (script: "curl -s http://localhost/rpc -d '{ \"field1\": 123 }' -H 'Content-Type: application/json'"){code} Could be re-written as: {code:java} def bodyMap = readJSON text: '{}' bodyMap.field1 = 123 def jsonStr = writeJSON json: bodyMap sh (script: "curl -s http://localhost/rpc -d '${jsonStr}' -H 'Content-Type: application/json'"){code} Granted you could just serialize to file and then pass that file to the curl command. |
Link |
New:
This issue is duplicated by |