Skip to main content
1 of 2
Sreehari
  • 11
  • 2
  • 6

Read and parse json file from workspace on slave node

I have a Jenkins job which runs on a slave node on another machine, both master and slave run on windows. The slave node is being run as a windows service. I am unable to read a json file from workspace in the slave node and parse it. The JSON file structure is like given below. I need to read the EmailProperties object and modify each of the properties and save the json file again. I have tried multiple suggestions on readFile() & readJSON(), but none of them is working. Any help on this would be highly appreciated.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "EmailProperties": {
      "MailPort": "587",
      "MailServer": "mydomainmailserver.outlook.com",
      "Password": "password123$",
      "Sender": "[email protected]"
    }
}
Sreehari
  • 11
  • 2
  • 6