Perform automated checkout and associate checkin against new workitem during build in TFS 2010

Answered Perform automated checkout and associate checkin against new workitem during build in TFS 2010

  • Wednesday, August 03, 2011 12:25 PM
     
     

    Hello All,

    I am currently working on automated checkout/checkin functionality to checkin newly generated binaries back into tfs.

    CheckOut/Checkin is working fine if I don't force checkin policy. My requirement is as follows:

    1. Checkout the files/folder.

    2. Create new workitem and assign it to current user who is doing the build.

    3. checkin newly generated dlls against workitem created in step 2.

    Here I am able to implement step 1 & 2 but I am struggling at step 3.

    Kindly help me with some pointers..

     

All Replies

  • Thursday, August 04, 2011 12:03 AM
     
     Answered Has Code

    3. checkin newly generated dlls against workitem created in step 2.

    http://msdn.microsoft.com/en-us/library/bb139040(v=VS.100).aspx 
    public int CheckIn(
    	PendingChange[] changes,
    	string author,
    	string comment,
    	CheckinNote checkinNote,
    	WorkItemCheckinInfo[] workItemChanges,
    	PolicyOverrideInfo policyOverride,
    	CheckinOptions checkinOptions
    )
    
    


    WorkItemchanges => Associated work item information. Associate the id of the newly created work item here.

    HTH
    Cheers, Tarun 


    Please remember to mark the replies as answers if they help.

    Tarun Arora

    Blog: http://geekswithblogs.net/TarunArora  Subscribe in a reader

    • Marked As Answer by ShikharJain Thursday, August 18, 2011 9:47 AM
    •  
  • Thursday, August 04, 2011 8:45 AM
     
     

    Hi Tarun,

    Thanks for your reply.

    I am using Invoke process activity in workflow to do the checkin/checkout operation where I invoke tf.exe. Also to create workitem I am using OpenWorkItem activity.

    All the activities are specified under Try Compile and Test block.

    I am struggling at how to get Id of newly created WorkItem in workflow and then associate it with checkin.

    Please help.

  • Friday, August 05, 2011 9:24 AM
    Moderator
     
     

    Hello Shikhar,

    Thanks for your post.

    How do you create that work item? Do you create it programmatically? If so, you can just get that new created work item ID by returning newCreatedWorkItem.Id. Please see:

    http://stackoverflow.com/questions/3824647/return-newly-created-tfs-work-item-id-using-tfs-api

    Thanks,


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Friday, August 05, 2011 1:14 PM
     
     

    Hi Vicky,

    VS 2010 provides OpenWorkItem activity that we can use in workflow to create workitem. I am using it and during build work item is getting created. but I dont know how to associate this workitem with my pending checkins and which command line tool/ activity I use to associate.

    Please help.

     

  • Saturday, August 06, 2011 12:02 PM
     
     

    OpenWorkItem activity returns a result of type workitem which has an id property

    http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.workitem.aspx

     

    You can't use tf.exe to associate workitems with changeset as per http://social.msdn.microsoft.com/forums/en-us/tfsversioncontrol/thread/1FA890B9-A6A4-40DD-8563-A49DB92F2A66 

    The above link is for TFS2005 and there is no indication that this has changed in 2010 as per

    http://msdn.microsoft.com/en-us/library/c327ca1z.aspx


    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies.

    Blog: http://lajak.wordpress.com

    Twitter: ahmedalasaad

  • Thursday, August 18, 2011 9:51 AM
     
     Answered

    Hi All,

    Thanks for your kind help.

    I changed the way I was trying to achieve my goal that is point 3.

    Now I created new custom code activity in which I create new work item, assign it to current user, associate pending checkin against newly created work item and then checkin.

    All is working as expected.

    Best Regards,

    Shikhar Jain

    • Marked As Answer by ShikharJain Thursday, August 18, 2011 9:51 AM
    •  
  • Friday, April 13, 2012 6:18 PM
     
     
    Hi, I have been struggling with this very same task I have to checkout files in our externals directory and when the build succeds checkin the newly built dlls replacing the ones in our externals. This task seems so hard to me. Do you by any chance have any examples that helped you achieve this? I would be very grateful to you...