This topic contains 3 replies, has 2 voices, and was last updated by
January 10, 2014 at 8:56 am #12478ParticipantPoints: 0Rank: Member
I have a number of scripts on a tool server which retrieve various bits of data, munge them around, and spit out emails and update databases. As part of some code clean up, I'm looking for tools and processes by which I can take source code and deploy it alternatively in either test or production scenarios. This would entail pushing to directories and setting variables to the appropriate test or production servers (DB end points and prod/test API targets). This sounds like a scenario for some sort of make like functionality. All the queries I've done seem to focus on using PowerShell to enhance make for other languages (C#, etc.) and not on build environments for PowerShell scripts themselves.
Before I take all my statically defined scripts and start re-inventing the wheel, has anyone tackled this problem before? Any tools or processes that you can recommend?
January 10, 2014 at 9:31 am #12479MemberPoints: 0Rank: Member
If I understand this correctly, you have scripts with hard-coded paths, and want to have another script that updates these values later? ie:
$someVariable = 'DB Endpoint 1' $someOtherVariable = 'API Target 1'
If that's the case, I would probably get away from hard-coding those values, and have the script read an XML config file instead. It would be very easy for your deployment script to generate new XML files on the fly (or just copy out a pre-made production or test file, if appropriate). Modifying another PowerShell script can be done, but there are a few potential pitfalls. For example, if you did that to a signed script, the signature would become invalid.
January 23, 2014 at 8:09 pm #12739ParticipantPoints: 0Rank: Member
Closing the loop on this, Dave's comment on using a config file was spot on. Referencing a common parameters file (in our case, we use a JSON formatted file and run it through ConvertFrom-Json) was a much more straightforward solution.
January 23, 2014 at 8:11 pm #12740MemberPoints: 0Rank: Member
No problem. 🙂
The topic ‘Tools and Best Practices for 'make' clones’ is closed to new replies.