Replace files with other files

Hi,

I am doing the following:

  1. I have a directory with 5 + json files. each with a unique name, but similar data inside them
  2. I need to either replace the entire file with another with the values all ready configured in the replacement file or use some type of variable substitution based on the file name.

So for example:
On the source control server I have a directory with several files for the various environments
1. clientJCRL_dev.json
2. clientJCRL_qa.json
3. clientFMS_dev.json
4. cleintFMS_qa.json
5. cleintHybrid_dev.json … etc… etc…

Each file has a json object in them like this but with different values
{
“ClientName”: “Job Corps Resource Library”,
“ClientId”: “app_jcrl”,
“Flow”: 2, “ClientUri”: “https://identityserver.io
}

When the deploy runs, I need to look at the file and then either do use the variable substitution tools based on the name or just replace the entire file with another stored on the source control server based on the environment…

What would be the best approach in octopus to accomplish this?

Hi there

Thanks for reaching out!

Given you need some custom logic to decide what behaviour to do, I’d suggest the easiest way is probably to write a script to do it.

You could potentially use the JSON Configuration Variables feature to do the replacement for all, and then have a subsequent script step that overwrites the file if need be.

Hope that helps!

Regards,
Matt