public static IContinuaCIProvider ContinuaCI(this ICakeContext context) { if (context == null) { throw new ArgumentNullException("context"); } var buildSystem = context.BuildSystem(); return(buildSystem.ContinuaCI); }
public static IJenkinsProvider Jenkins(this ICakeContext context) { if (context == null) { throw new ArgumentNullException("context"); } var buildSystem = context.BuildSystem(); return(buildSystem.Jenkins); }
public static IAppVeyorProvider AppVeyor(this ICakeContext context) { if (context == null) { throw new ArgumentNullException("context"); } var buildSystem = context.BuildSystem(); return(buildSystem.AppVeyor); }
public static ITeamCityProvider TeamCity(this ICakeContext context) { if (context == null) { throw new ArgumentNullException("context"); } var buildSystem = context.BuildSystem(); return(buildSystem.TeamCity); }
public static IBambooProvider Bamboo(this ICakeContext context) { if (context == null) { throw new ArgumentNullException("context"); } var buildSystem = context.BuildSystem(); return(buildSystem.Bamboo); }
public static IMyGetProvider MyGet(this ICakeContext context) { if (context == null) { throw new ArgumentNullException("context"); } var buildSystem = context.BuildSystem(); return(buildSystem.MyGet); }
public static string GetBuildAgent(this ICakeContext context) { var buildSystem = context.BuildSystem(); return(buildSystem.Provider switch { BuildProvider.Local => "Local", BuildProvider.AzurePipelines => "AzurePipelines", BuildProvider.GitHubActions => "GitHubActions", _ => string.Empty });
public static IGitLabCIProvider GitLabCI(this ICakeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var buildSystem = context.BuildSystem(); return(buildSystem.GitLabCI); }
public static ITFBuildProvider TFBuild(this ICakeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var buildSystem = context.BuildSystem(); return(buildSystem.TFBuild); }
public static IBitbucketPipelinesProvider BitbucketPipelines(this ICakeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var buildSystem = context.BuildSystem(); return(buildSystem.BitbucketPipelines); }
public static void StartGroup(this ICakeContext context, string title) { var buildSystem = context.BuildSystem(); var startGroup = "[group]"; if (buildSystem.IsRunningOnAzurePipelines || buildSystem.IsRunningOnAzurePipelinesHosted) { startGroup = "##[group]"; } else if (buildSystem.IsRunningOnGitHubActions) { startGroup = "::group::"; } context.Information($"{startGroup}{title}"); }
public static void EndGroup(this ICakeContext context) { var buildSystem = context.BuildSystem(); var endGroup = "[endgroup]"; if (buildSystem.IsRunningOnAzurePipelines || buildSystem.IsRunningOnAzurePipelinesHosted) { endGroup = "##[endgroup]"; } else if (buildSystem.IsRunningOnGitHubActions) { endGroup = "::endgroup::"; } context.Information($"{endGroup}"); }
public static string GetBranch(this ICakeContext context) { var buildSystem = context.BuildSystem(); string repositoryBranch = context.ExecGitCmd("rev-parse --abbrev-ref HEAD").Single(); if (buildSystem.IsRunningOnAzurePipelines) { repositoryBranch = buildSystem.AzurePipelines.Environment.Repository.SourceBranchName; } else if (buildSystem.IsRunningOnGitHubActions) { repositoryBranch = buildSystem.GitHubActions.Environment.Workflow.Ref.Replace("refs/heads/", ""); } return(repositoryBranch); }
public static bool IsOriginalRepo(this ICakeContext context) { var buildSystem = context.BuildSystem(); string repositoryName = string.Empty; if (buildSystem.IsRunningOnAzurePipelines) { repositoryName = buildSystem.AzurePipelines.Environment.Repository.RepoName; } else if (buildSystem.IsRunningOnGitHubActions) { repositoryName = buildSystem.GitHubActions.Environment.Workflow.Repository; } return(!string.IsNullOrWhiteSpace(repositoryName) && StringComparer.OrdinalIgnoreCase.Equals($"{Constants.RepoOwner}/{Constants.Repository}", repositoryName)); }
public static bool IsOriginalRepo(this ICakeContext context) { var buildSystem = context.BuildSystem(); string repositoryName = string.Empty; if (buildSystem.IsRunningOnAppVeyor) { repositoryName = buildSystem.AppVeyor.Environment.Repository.Name; } else if (buildSystem.IsRunningOnAzurePipelines) { repositoryName = buildSystem.AzurePipelines.Environment.Repository.RepoName; } else if (buildSystem.IsRunningOnGitHubActions) { repositoryName = buildSystem.GitHubActions.Environment.Workflow.Repository; } context.Information("Repository Name: {0}", repositoryName); return(!string.IsNullOrWhiteSpace(repositoryName) && StringComparer.OrdinalIgnoreCase.Equals("gittools/GitVersion", repositoryName)); }
public static bool IsMainBranch(this ICakeContext context) { var buildSystem = context.BuildSystem(); string repositoryBranch = context.ExecGitCmd("rev-parse --abbrev-ref HEAD").Single(); if (buildSystem.IsRunningOnAppVeyor) { repositoryBranch = buildSystem.AppVeyor.Environment.Repository.Branch; } else if (buildSystem.IsRunningOnAzurePipelines || buildSystem.IsRunningOnAzurePipelinesHosted) { repositoryBranch = buildSystem.AzurePipelines.Environment.Repository.SourceBranchName; } else if (buildSystem.IsRunningOnGitHubActions) { repositoryBranch = buildSystem.GitHubActions.Environment.Workflow.Ref.Replace("refs/heads/", ""); } context.Information("Repository Branch: {0}", repositoryBranch); return(!string.IsNullOrWhiteSpace(repositoryBranch) && StringComparer.OrdinalIgnoreCase.Equals("main", repositoryBranch)); }
public static Options GetBuildOptions(this ICakeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var options = new Options(); var buildSystem = context.BuildSystem(); // Platform options.IsLocalBuild = buildSystem.IsLocalBuild; options.IsMonoPresent = IsMonoOnPath(); options.IsRunningOnUnix = context.IsRunningOnUnix(); options.IsRunningOnWindows = context.IsRunningOnWindows(); options.IsRunningOnAppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; // Repository options.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; options.IsMainBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.AppVeyor.Environment.Repository.Branch); options.IsTagged = IsBuildTagged(buildSystem); // Features on/off options.SkipGitVersion = StringComparer.OrdinalIgnoreCase.Equals("true", context.EnvironmentVariable("SKIP_GITVERSION")); options.SkipCoverage = StringComparer.OrdinalIgnoreCase.Equals("true", context.EnvironmentVariable("SKIP_COVERAGE")); // GitVersion tool is used to calculate semantic version based on repo history if (buildSystem.AppVeyor.IsRunningOnAppVeyor) { // AppVeyor provides GitVersion functionality that can be enabled via appveyor.yml: // before_build: // -ps: gitversion $env:APPVEYOR_BUILD_FOLDER /l console /output buildserver /nofetch /b $env:APPVEYOR_REPO_BRANCH // // GitVersion from build script ("else branch" below) fails on AppVeyor with the next exception: // "An unexpected error occurred: LibGit2Sharp.LibGit2SharpException: this remote has never connected". // This issue can be tracked down to libgit2 library and its method "git_remote_ls" (https://github.com/libgit2/libgit2/blob/master/src/remote.c#L713). // TODO: Investigate why AppVeyor's GitVersion works but our one suffers from that problem while basically under the hood this is the same tool. options.AssemblySemVer = context.EnvironmentVariable("GitVersion_AssemblySemVer"); options.MajorMinorPatch = context.EnvironmentVariable("GitVersion_MajorMinorPatch"); options.InformationalVersion = context.EnvironmentVariable("GitVersion_InformationalVersion"); options.FullSemVer = context.EnvironmentVariable("GitVersion_FullSemVer"); options.SemVer = context.EnvironmentVariable("GitVersion_SemVer"); options.NuGetVersion = context.EnvironmentVariable("GitVersion_NuGetVersion"); } else { var version = RunGitVersion(context, options); options.AssemblySemVer = version.AssemblySemVer; options.MajorMinorPatch = version.MajorMinorPatch; options.InformationalVersion = version.InformationalVersion; options.FullSemVer = version.FullSemVer; options.SemVer = version.SemVer; options.NuGetVersion = version.NuGetVersion; } if (!string.IsNullOrEmpty(options.NuGetVersion)) { var pos = options.NuGetVersion.IndexOf('-'); if (pos >= 0) { options.NuGetVersionSuffix = options.NuGetVersion.Substring(pos + 1); } } // Artifacts var artifactsDir = Path.Combine("artifacts", "v" + options.SemVer); var testResultsDir = Path.Combine(artifactsDir, "test-results"); var nugetDir = Path.Combine(artifactsDir, "nuget"); options.DirectoriesToClean = new[] { artifactsDir, testResultsDir, nugetDir }; options.TestResultsDir = testResultsDir; options.OpenCoverXml = Path.Combine(testResultsDir, "OpenCover.xml"); options.CoverageReportDir = Path.Combine(testResultsDir, "report"); options.OutputPackagesDir = nugetDir; return(options); }