Search code examples
powershelltfstfs-2015continuous-deployment

How to take code backup in TFS 2015 during Release Management/Pipeline


I've done Build for my code in TFS 2015. Now i'm configuring CD, my tasks would be

  1. Take Backup of existing release code
  2. Deploy build artifact to my server
  3. Rollback task if deployment fails

I'm struck with Task 1 : Take backup of exiting release code.

I would prefer using PowerShell task as suggested over here, as my my release server path differs with different an ID {mulitple paths with multiple Id's]


Solution

  • How to take code backup in TFS 2015 during Release Management/Pipeline

    Indeed, Backing up existing release code on the server is really a tricky issue, if your release server path differs with different an ID. It seems we have to create several task to back up release code from different release server path or we have to write the scripts(PS, Batch) to back up those release code.

    To resolve this question, I would like provide a workaround, you can check if it works for you. The tasks would be:

    1. Deploy build artifact to the server.
    2. Use Copy task to back up the build artifact to the local folder of the TFS server machine with condition Only when all previous tasks have succeeded.
    3. Deploy backup artifact to the server with condition Only when all previous tasks failed (Also check the option Clear Target Folder under the Advanced tab).

    Some explanations for tasks 2 and task 3:

    Task2: This steps is use to back up the release code of the last successful deployment, and save it to the local folder on the server.

    Task3: This steps is used to deploy the back up the release code to overwrite the release code that failed to deploy before, if the previous deployment task failed.

    Hope this helps.