1

We are using VSTS for CI and CD in my team, we got over 40 repositories which are separated projects. but all of them have to run the same PowerShell script in one of their Build steps.

the PowerShell file is bigger too big to be kept as the inline script, so we need to save it inside a file. obviously, I got a copy of the PowerShell file in each repository.

Problem:

Now whenever I need to update the script, then I end up to update it in every repository, which is over 40 at the moment. I think there should be a better approach. Is there any way that I can put my script in one single repo (a repo dedicated to holding the script) then I use it within each build, therefore we I need to update it I only need to update it once.

1
  • Couldn't you just add it as a build step to each repo to check out the script from its own repo and utilize it that way? Commented Apr 3, 2018 at 17:04

2 Answers 2

3

There are a few options.

My general recommendation is to publish the script as a package (NuGet or otherwise) and restore it during your application builds. This allows consumers to stay "pinned" to a known-good, known-working version, and update on a schedule that works for them.

Another option is to add a submodule to each repository that requires the script dependency, then initialize the submodule during the build process.

A third option is to turn the shared script into a VSTS build task or extension. This is extensively documented and easily located so I won't belabor the point by including instructions for doing that here.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the help, could you tell me more about option 2, please.
0

You can add a git repository to store your powershell file. Then add a build step to get you file from that repository during build and use it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.