View Full Version : Automating check out /check in of each step?
BallyUK
08-30-2005, 07:19 AM
The company I work for uses Visual Sourcesafe, and Visual Build Pro. I need to check out the current step, build it, then check it back in (so the version number in the project file is altered correctly, for instance in a .VBP for visual basic). I also need to make it so that if the file cannot be checked out (because someone else has the file checked out) that it does not continue with the build / check in.
How can I script something along these lines or automate it somehow ...
if not isCheckedOut(currStep.project) then
checkOut(currStep.project)
build(currStep)
checkIn(currStep.project)
Thanks for any advice in advance.
kinook
08-30-2005, 07:28 AM
It's normally automatic. If the checkout step fails (which it will if a file that you attempt to checkout is already checked out [provided that you don't have multiple checkouts enabled in VSS]) and the step is not marked to ignore failure, the build will not continue.
BallyUK
08-30-2005, 07:36 AM
Sorry, maybe I phrased my question badly. What I'm after is some generic piece of code that I can run before and after each step (preferably automatically so i dont have to add it before / after each step) which checks out that steps project then checks it back in after build.
The machine we use to build our software keeps a local copy of the entire of sourcesafe which is automatically grabbed at the start of our Build script, so with each step we are compiling from that local (non-checked out) project. The problem is, the original project files are not registering any version change because they were never updated (checked out and in). So although the version number is being udpated LOCALLY each time, the version in sourcesafe still has the old version number.
Because our build script is so large we need the ability to be able to build an individual project, so we dont want to check out ALL of our projects each time. So basically i want something like the following.
Steps...
Get All of SourceSafe
Build App1 (auto check out / in)
Build App2 (auto check out / in)
Build App3 (auto check out / in)
Thanks for the prompt response, sorry if I'm not explaining this very well.
kinook
08-30-2005, 09:28 AM
One way to do this would be to create a subroutine that generically checks out a VBP, builds it, and checks it in, and then call this subroutine for each project that needs to be built.
BallyUK
08-30-2005, 09:34 AM
Thats really what i'm getting at, how would I build a 'generic' sub.
How can i get the filename of the current project so that I can check it out / in? I had a look at the pre-defined variables but I couldnt quite what I needed.
kinook
08-30-2005, 09:42 AM
See the Advanced.bld sample. The 'Call a Subroutine' step passes a macro SUB_PARM1 to the 'Another Sub' subroutine, which uses that macro in a Log Message step.
BallyUK
08-30-2005, 10:05 AM
Okay, thanks that is how I pass values to a sub - but how can i pass the filename of the main step in that group? If i have to type the entire filename again for the checkout / checkin step then i'm better creating 40 checkout and 40 checkin steps for each of the 40 programs. It just seems very tedious :(
kinook
08-30-2005, 10:22 AM
What do you mean by 'the filename of the main step in that group'?
BallyUK
08-30-2005, 10:27 AM
Okay, we tend to put each app in its own group
so what i really want is
mygroup
-Checkthisprogout (generically so i dont have to type info in)
-buildthisprog
(the main step in the group, probably referring to a visual basic project, so a local .vbp file)
-Checkthisprogin (generically so i dont have to type info in)
kinook
08-30-2005, 11:07 AM
I'm not sure if you are using 'group' and 'project' interchangeably, or if you actually have VBGs that each contain one VBP, but it sounds like you want a single step in your .bld file for each .VBP that might get built (so that you can selectively include only the ones you want to build at a certain time). You can use a single Subroutine Call step for each .VBP file, which passes the .VBP filename in a macro, then use that filename in the subroutine to checkout, build, and checkin. You will need to convert the filename to a VSS path for the checkin/out steps, and how that conversion is done depends on your directory and VSS structure. See the attached sample for one approach. Let me know if that helps or if I'm totally off track.
BallyUK
08-30-2005, 11:12 AM
Thanks very much for all your help so far, im off home now but i'll check this out first thing in the morning.
BallyUK
08-31-2005, 03:37 AM
I think with this and looking at the other samples I have this thing licked, thanks a lot for your help!
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.