Search code examples
tfstfsbuildcakebuild

Cake Build auto merge functionality


I'm using cakebuid as my build tool for TFS 2017 Update 2 and trying to implement the traditional Git Flow. In this flow, there are a few automatic merges that happen every time changes get into master, those changes need to be propagated to the develop branch. Using cake I can run a PowerShell script or use LibGit2Sharp to accomplish the automatic merge for the best case scenarios. But, what about when the merge has conflicts? Do I need to fail the whole build because the merge process fail? We have certainly something to deal with merges in TFS, this is no other than the Pull Request.

Question

Is there any tool or add-in for cake that allows me to create Pull Request during the execution of a build step?


Solution

  • Finally, I spend sometimes creating the package:

    Nuget: https://www.nuget.org/packages/Cake.Tfs.AutoMerge

    GitHub: https://github.com/mabreuortega/Cake.Tfs

    The way you can use it now is similar to this:

    Task("Merge")
        .Does(c => {
            CreateAutoMergePullRequest(
                new AutoMergeSettings 
                {
                            // Required
                    CollectionUri = "https://{instance}/{collection-name}",
                    ProjectName = "project-name",
                    RepositoryName = "repository-name",
                    SourceBranch = "refs/heads/release/1.0.0",
                    TargetBranch = "refs/heads/develop",
                    Title = "[Auto Merge from Release]",
    
                            // Optional
                    Description = "Brief description of the changes about to get merge",
    
                            // Control
                    DeleteSourceBranch = false,
                    SquashMerge = false,
                    OverridePolicies = true,
                    AutoComplete = true,
                    AutoApprove = true
                });
        });
    

    Any suggestions, please use the GitHub issue tracker.

    Hope this help!