Skip to main content
Updated the question with properties file example
Source Link
Sreehari
  • 11
  • 2
  • 6

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.

JSON file:

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

Properties file:

[transformation]
json_dev_EmailProperties.MailPort = 663
json_dev_EmailProperties.MailServer = devmailserver.outlook.com
json_dev_EmailProperties.Password = DevPassword123$
json_dev_EmailProperties.Sender = [email protected]

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]"
    }
}

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.

JSON file:

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

Properties file:

[transformation]
json_dev_EmailProperties.MailPort = 663
json_dev_EmailProperties.MailServer = devmailserver.outlook.com
json_dev_EmailProperties.Password = DevPassword123$
json_dev_EmailProperties.Sender = [email protected]
Source Link
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]"
    }
}