Convert Json String to Key/Value String using Groovy Jenkins

Veeresh Kumar
Oct 1, 2021

Most of the times, we need a dynamic or automated way of converting the given data into some format we need for processing or passing as input to other functions/programs.

Recently, I needed Json String output received from some application API response to be converted to Key/Value pair dynamically when the jenkins pipeline runs.

The best option thought was having Groovy function in pipeline, which takes json string input and returns output as key/value string.

Here we go !!!

Here is the output of the above function.

Note: The above script can be run on any groovy compiler or you can copy paste the above content to jenkins pipeline and run it.

Hope this helps …!! Happy Scripting …!!

--

--

Veeresh Kumar

He is a Sr. DevOps Engineer loves to automate cloud infrastructure and App deployments. #Terraform #Azure #Jenkins #Ansible #Chef #Bash #PowerShell #AWS #GCP