cancel
Showing results for 
Search instead for 
Did you mean: 

Pull code from repository on VM startup?

SOLVED
Highlighted
Occasional Contributor

Pull code from repository on VM startup?

Hello Everyone,

 

I tried doing some searching, but wasn't able to find help related to what we're trying to do with a new VM setup. 

 

We are currently being upgraded to new windows 10 vm's with the plan that we will have one master that all of our test runner machines will be created from on start/restart.  Once the vm's are created, they will just have the software installed we need to run our tests through TestExecute.  When a vm is restarted, it will then be re-built each time from the master to try and keep the machine as clean as possible.

 

The part we're trying to figure out is how we can on vm startup pull code from our TFS repository so the VM has the latest version of code to run tests/processes we use it for.  This restart would most likely happen over the weekend and we have processes that run daily early in the morning (2 AM) that would need this code to be able to run when no one is there to push code to the vm.  In our current setup, we are able to copy code manually down to our VM's that are not rebuilt upon a restart and thus keep the code necessary to run day to day.

 

Any suggestions on how to approach this are appreciated, thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Pull code from repository on VM startup?

We're using a commandline call in Task Scheduler.  We have ours triggered on a timer but you can trigger off of logon or startup.

"C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe" get *.* /force /recursive


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

Re: Pull code from repository on VM startup?

We're using a commandline call in Task Scheduler.  We have ours triggered on a timer but you can trigger off of logon or startup.

"C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe" get *.* /force /recursive


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Highlighted
Community Hero

Re: Pull code from repository on VM startup?

At a previous job, we did something similar to what @tristaanogre describes, but we used Bamboo to launch everything.  

 

Highlighted
Occasional Contributor

Re: Pull code from repository on VM startup?

Thanks for the quick reply.

 

From the command line code listed there, aside from needing a version of visual studio installed on the VM, I'm guessing you need to have an account logging in to the VM that has access to the TFS repository and has mapping defined to pull to a location (in this case, defined on the master vm so it exists on runner vm creation/recreation), yes?  Or is it possible in the command line string to define permissions and the folder location to write the code to?  Our test user for our vm's currently doesn't have access to our repository since we've only manually pushed code to the vm's so far.

Highlighted
Community Hero

Re: Pull code from repository on VM startup?

You are correct, you will need to set up that test user to have at least a level of access to retrieve from the repository.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Occasional Contributor

Re: Pull code from repository on VM startup?

Sounds good, thanks again.  I'll pass this over to the others working on our upgrade to see if this is the solution they were hoping for.

New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to pass custom command-line arguments as a test parameter for the TechCorner tag!

Will you dare to take the challenge?


Top Kudoed Authors