/// <summary> /// Initializes a new instance of the <see cref="BuildSystem"/> class. /// </summary> /// <param name="appVeyorProvider">The AppVeyor Provider.</param> /// <param name="teamCityProvider">The TeamCity Provider.</param> /// <param name="myGetProvider">The MyGet Provider.</param> /// <param name="bambooProvider">The Bamboo Provider.</param> /// <param name="continuaCIProvider">The Continua CI Provider.</param> public BuildSystem(IAppVeyorProvider appVeyorProvider, ITeamCityProvider teamCityProvider, IMyGetProvider myGetProvider, IBambooProvider bambooProvider, IContinuaCIProvider continuaCIProvider) { if (appVeyorProvider == null) { throw new ArgumentNullException("appVeyorProvider"); } if (teamCityProvider == null) { throw new ArgumentNullException("teamCityProvider"); } if (myGetProvider == null) { throw new ArgumentNullException("myGetProvider"); } if (bambooProvider == null) { throw new ArgumentNullException("bambooProvider"); } if (continuaCIProvider == null) { throw new ArgumentNullException("continuaCIProvider"); } _appVeyorProvider = appVeyorProvider; _teamCityProvider = teamCityProvider; _myGetProvider = myGetProvider; _bambooProvider = bambooProvider; _continuaCIProvider = continuaCIProvider; }
/// <summary> /// Adds a warning message to the AppVeyor build log. /// </summary> /// <param name="provider">The AppVeyor provider.</param> /// <param name="format">The message.</param> /// <param name="args">The args.</param> public static void AddErrorMessage(this IAppVeyorProvider provider, string format, params object[] args) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } provider.AddMessage(string.Format(CultureInfo.InvariantCulture, format, args), AppVeyorMessageCategoryType.Error); }
/// <summary> /// Adds an informational message to the AppVeyor build log /// </summary> /// <param name="provider">The AppVeyor provider</param> /// <param name="format">The message</param> /// <param name="args">The args</param> public static void AddInformationalMessage(this IAppVeyorProvider provider, string format, params object[] args) { if (provider == null) { throw new ArgumentNullException("provider"); } provider.AddMessage(string.Format(CultureInfo.InvariantCulture, format, args)); }
/// <summary> /// Adds a warning message to the AppVeyor build log. /// </summary> /// <param name="provider">The AppVeyor provider.</param> /// <param name="message">The message.</param> /// <param name="exception">The exception.</param> public static void AddErrorMessage(this IAppVeyorProvider provider, string message, Exception exception) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } provider.AddMessage(message, AppVeyorMessageCategoryType.Error, exception?.ToString()); }
/// <summary> /// Tags the build when running on Appveyor or AzureDevOps (GitLab does not support this). /// Note that if <see cref="ShouldStop"/> is true, " (Skipped)" is appended. /// </summary> /// <returns>This info object (allowing fluent syntax).</returns> public StandardGlobalInfo SetCIBuildTag() { string AddSkipped(string s) => ShouldStop ? s + " (Skipped)" : s; void AzurePipelineUpdateBuildVersion(SimpleRepositoryInfo gitInfo) { // Azure (formerly VSTS, formerly VSO) analyzes the stdout to set its build number. // On clash, the default Azure/VSTS/VSO build number is used: to ensure that the actual // version will be always be available we need to inject a uniquifier. string buildVersion = AddSkipped($"{gitInfo.SafeVersion}_{DateTime.UtcNow:yyyyMMdd-HHmmss}"); Cake.Information($"Using VSTS build number: {buildVersion}"); string buildInstruction = $"##vso[build.updatebuildnumber]{buildVersion}"; Console.WriteLine(); Console.WriteLine(buildInstruction); Console.WriteLine(); } void AppVeyorUpdateBuildVersion(IAppVeyorProvider appVeyor, SimpleRepositoryInfo gitInfo) { try { appVeyor.UpdateBuildVersion(AddSkipped(gitInfo.SafeVersion)); } catch { appVeyor.UpdateBuildVersion(AddSkipped($"{gitInfo.SafeVersion} ({appVeyor.Environment.Build.Number})")); } } var gitlab = Cake.GitLabCI(); if (gitlab.IsRunningOnGitLabCI) { // damned, we can't tag the pipeline/job. } else { IAppVeyorProvider appVeyor = Cake.AppVeyor(); if (appVeyor.IsRunningOnAppVeyor) { AppVeyorUpdateBuildVersion(appVeyor, _gitInfo); } else { ITFBuildProvider vsts = Cake.TFBuild(); if (vsts.IsRunningOnAzurePipelinesHosted || vsts.IsRunningOnAzurePipelines) { AzurePipelineUpdateBuildVersion(_gitInfo); } } } return(this); }
/// <summary> /// Initializes a new instance of the <see cref="BuildSystem"/> class. /// </summary> /// <param name="appVeyorProvider">The AppVeyor Provider.</param> /// <param name="teamCityProvider">The TeamCity Provider.</param> public BuildSystem(IAppVeyorProvider appVeyorProvider, ITeamCityProvider teamCityProvider) { if (appVeyorProvider == null) { throw new ArgumentNullException("appVeyorProvider"); } if (teamCityProvider == null) { throw new ArgumentNullException("teamCityProvider"); } _appVeyorProvider = appVeyorProvider; _teamCityProvider = teamCityProvider; }
public void Setup() { _environment = FakeEnvironment.CreateWindowsEnvironment(); _log = new FakeLog(); _arguments = Substitute.For <ICakeArguments>(); _appVeyor = Substitute.For <IAppVeyorProvider>(); _azure = Substitute.For <ITFBuildProvider>(); _appEnvironment = new AppVeyorEnvironmentInfo(_environment); _appVeyor.Environment.Returns(_appEnvironment); _globber = Substitute.For <IGlobber>(); _fileSystem = new FakeFileSystem(_environment); _processRunner = Substitute.For <IProcessRunner>(); _toolLocator = Substitute.For <IToolLocator>(); }
/// <summary> /// Initializes a new instance of the <see cref="BuildSystem" /> class. /// </summary> /// <param name="appVeyorProvider">The AppVeyor Provider.</param> /// <param name="teamCityProvider">The TeamCity Provider.</param> /// <param name="myGetProvider">The MyGet Provider.</param> /// <param name="bambooProvider">The Bamboo Provider.</param> /// <param name="continuaCIProvider">The Continua CI Provider.</param> /// <param name="jenkinsProvider">The Jenkins Provider.</param> /// <param name="bitriseProvider">The Bitrise Provider.</param> /// <param name="travisCIProvider">The Travis CI provider.</param> /// <param name="bitbucketPipelinesProvider">The Bitbucket Pipelines provider.</param> public BuildSystem(IAppVeyorProvider appVeyorProvider, ITeamCityProvider teamCityProvider, IMyGetProvider myGetProvider, IBambooProvider bambooProvider, IContinuaCIProvider continuaCIProvider, IJenkinsProvider jenkinsProvider, IBitriseProvider bitriseProvider, ITravisCIProvider travisCIProvider, IBitbucketPipelinesProvider bitbucketPipelinesProvider) { if (appVeyorProvider == null) { throw new ArgumentNullException("appVeyorProvider"); } if (teamCityProvider == null) { throw new ArgumentNullException("teamCityProvider"); } if (myGetProvider == null) { throw new ArgumentNullException("myGetProvider"); } if (bambooProvider == null) { throw new ArgumentNullException("bambooProvider"); } if (continuaCIProvider == null) { throw new ArgumentNullException("continuaCIProvider"); } if (jenkinsProvider == null) { throw new ArgumentNullException("jenkinsProvider"); } if (bitriseProvider == null) { throw new ArgumentNullException("bitriseProvider"); } if (travisCIProvider == null) { throw new ArgumentNullException("travisCIProvider"); } if (bitbucketPipelinesProvider == null) { throw new ArgumentNullException("bitbucketPipelinesProvider"); } _appVeyorProvider = appVeyorProvider; _teamCityProvider = teamCityProvider; _myGetProvider = myGetProvider; _bambooProvider = bambooProvider; _continuaCIProvider = continuaCIProvider; _jenkinsProvider = jenkinsProvider; _bitriseProvider = bitriseProvider; _travisCIProvider = travisCIProvider; _bitbucketPipelinesProvider = bitbucketPipelinesProvider; }
/// <summary> /// Initializes a new instance of the <see cref="BuildSystem" /> class. /// </summary> /// <param name="appVeyorProvider">The AppVeyor Provider.</param> /// <param name="teamCityProvider">The TeamCity Provider.</param> /// <param name="myGetProvider">The MyGet Provider.</param> /// <param name="bambooProvider">The Bamboo Provider.</param> /// <param name="continuaCIProvider">The Continua CI Provider.</param> /// <param name="jenkinsProvider">The Jenkins Provider.</param> /// <param name="bitriseProvider">The Bitrise Provider.</param> /// <param name="travisCIProvider">The Travis CI provider.</param> /// <param name="bitbucketPipelinesProvider">The Bitbucket Pipelines provider.</param> public BuildSystem(IAppVeyorProvider appVeyorProvider, ITeamCityProvider teamCityProvider, IMyGetProvider myGetProvider, IBambooProvider bambooProvider, IContinuaCIProvider continuaCIProvider, IJenkinsProvider jenkinsProvider, IBitriseProvider bitriseProvider, ITravisCIProvider travisCIProvider, IBitbucketPipelinesProvider bitbucketPipelinesProvider) { if (appVeyorProvider == null) { throw new ArgumentNullException(nameof(appVeyorProvider)); } if (teamCityProvider == null) { throw new ArgumentNullException(nameof(teamCityProvider)); } if (myGetProvider == null) { throw new ArgumentNullException(nameof(myGetProvider)); } if (bambooProvider == null) { throw new ArgumentNullException(nameof(bambooProvider)); } if (continuaCIProvider == null) { throw new ArgumentNullException(nameof(continuaCIProvider)); } if (jenkinsProvider == null) { throw new ArgumentNullException(nameof(jenkinsProvider)); } if (bitriseProvider == null) { throw new ArgumentNullException(nameof(bitriseProvider)); } if (travisCIProvider == null) { throw new ArgumentNullException(nameof(travisCIProvider)); } if (bitbucketPipelinesProvider == null) { throw new ArgumentNullException(nameof(bitbucketPipelinesProvider)); } AppVeyor = appVeyorProvider; TeamCity = teamCityProvider; MyGet = myGetProvider; Bamboo = bambooProvider; ContinuaCI = continuaCIProvider; Jenkins = jenkinsProvider; Bitrise = bitriseProvider; TravisCI = travisCIProvider; BitbucketPipelines = bitbucketPipelinesProvider; }
public static void ConfigureAppVeyorEnvironment(ICakeContext ctx, TaskConfig cfg) { IAppVeyorProvider appveyor = ctx.AppVeyor(); if (!appveyor.IsRunningOnAppVeyor) { throw new TaskConfigException("Not running in AppVeyor"); } EnvConfig env = cfg.Load <EnvConfig>(); env.IsCi = true; env.Version.BuildNumber = appveyor.Environment.Build.Number.ToString(); env.Version.Build = $"{env.Version.Primary}-build.{env.Version.BuildNumber}"; }
/// <summary> /// Tags the build when running on Appveyor or AzureDevOps (GitLab does not support this). /// Note that if <see cref="ShouldStop"/> is true, " (Skipped)" is appended. /// </summary> /// <returns>This info object (allowing fluent syntax).</returns> public StandardGlobalInfo SetCIBuildTag() { string AddSkipped(string s) => ShouldStop ? s + " (Skipped)" : s; string ComputeAzurePipelineUpdateBuildVersion(SimpleRepositoryInfo gitInfo) { // Azure (formerly VSTS, formerly VSO) analyzes the stdout to set its build number. // On clash, the default Azure/VSTS/VSO build number is used: to ensure that the actual // version will be always be available we need to inject a uniquifier. string buildVersion = AddSkipped($"{gitInfo.SafeVersion}_{DateTime.UtcNow:yyyyMMdd-HHmmss}"); Cake.Information($"Using VSTS build number: {buildVersion}"); return($"##vso[build.updatebuildnumber]{buildVersion}"); } void AzurePipelineUpdateBuildVersion(string buildInstruction) { Console.WriteLine(); Console.WriteLine(buildInstruction); Console.WriteLine(); } IAppVeyorProvider appVeyor = Cake.AppVeyor(); ITFBuildProvider vsts = Cake.TFBuild(); try { string azureVersion = ComputeAzurePipelineUpdateBuildVersion(_gitInfo); string appveyorVersion = AddSkipped(_gitInfo.SafeVersion); if (appVeyor.IsRunningOnAppVeyor) //Warning: { appVeyor.UpdateBuildVersion(appveyorVersion); } if (vsts.IsRunningOnAzurePipelinesHosted || vsts.IsRunningOnAzurePipelines) { AzurePipelineUpdateBuildVersion(azureVersion); } } catch (Exception e) { Cake.Warning("Could not set the Build Version !!!"); Cake.Warning(e); } return(this); }
/// <summary> /// Tags the build when running on Appveyor or AzureDevOps (GitLab does not support this). /// Note that if <see cref="ShouldStop"/> is true, " (Skipped)" is appended. /// </summary> /// <returns>This info object (allowing fluent syntax).</returns> public StandardGlobalInfo SetCIBuildTag() { string AddSkipped(string s) => ShouldStop ? s + " (Skipped)" : s; string ComputeAzurePipelineUpdateBuildVersion(ICommitBuildInfo buildInfo) { // Azure (formerly VSTS, formerly VSO) analyzes the stdout to set its build number. // On clash, the default Azure/VSTS/VSO build number is used: to ensure that the actual // version will be always be available we need to inject a uniquifier. string buildVersion = AddSkipped($"{buildInfo.Version}_{DateTime.UtcNow:yyyyMMdd-HHmmss}"); Cake.Information($"Using Azure build number: {buildVersion}"); return($"##vso[build.updatebuildnumber]{buildVersion}"); } void AzurePipelineUpdateBuildVersion(string buildInstruction) { Console.WriteLine(); Console.WriteLine(buildInstruction); Console.WriteLine(); } IAppVeyorProvider appVeyor = Cake.AppVeyor(); IAzurePipelinesProvider azure = Cake.AzurePipelines(); try { if (appVeyor.IsRunningOnAppVeyor) { appVeyor.UpdateBuildVersion(AddSkipped(BuildInfo.Version.ToString())); } if (azure.IsRunningOnAzurePipelines) { string azureVersion = ComputeAzurePipelineUpdateBuildVersion(BuildInfo); AzurePipelineUpdateBuildVersion(azureVersion); } } catch (Exception e) { Cake.Warning("Could not set the Build Version!"); Cake.Warning(e); } return(this); }
/// <summary> /// Initializes a new instance of the <see cref="BuildSystem" /> class. /// </summary> /// <param name="appVeyorProvider">The AppVeyor Provider.</param> /// <param name="teamCityProvider">The TeamCity Provider.</param> /// <param name="myGetProvider">The MyGet Provider.</param> /// <param name="bambooProvider">The Bamboo Provider.</param> /// <param name="continuaCIProvider">The Continua CI Provider.</param> /// <param name="jenkinsProvider">The Jenkins Provider.</param> /// <param name="bitriseProvider">The Bitrise Provider.</param> /// <param name="travisCIProvider">The Travis CI provider.</param> /// <param name="bitbucketPipelinesProvider">The Bitbucket Pipelines provider.</param> /// <param name="goCDProvider">The Go.CD provider.</param> /// <param name="gitlabCIProvider">The GitLab CI provider.</param> /// <param name="tfBuildProvider">The TF Build provider.</param> public BuildSystem( IAppVeyorProvider appVeyorProvider, ITeamCityProvider teamCityProvider, IMyGetProvider myGetProvider, IBambooProvider bambooProvider, IContinuaCIProvider continuaCIProvider, IJenkinsProvider jenkinsProvider, IBitriseProvider bitriseProvider, ITravisCIProvider travisCIProvider, IBitbucketPipelinesProvider bitbucketPipelinesProvider, IGoCDProvider goCDProvider, IGitLabCIProvider gitlabCIProvider, ITFBuildProvider tfBuildProvider) { if (appVeyorProvider == null) { throw new ArgumentNullException(nameof(appVeyorProvider)); } if (teamCityProvider == null) { throw new ArgumentNullException(nameof(teamCityProvider)); } if (myGetProvider == null) { throw new ArgumentNullException(nameof(myGetProvider)); } if (bambooProvider == null) { throw new ArgumentNullException(nameof(bambooProvider)); } if (continuaCIProvider == null) { throw new ArgumentNullException(nameof(continuaCIProvider)); } if (jenkinsProvider == null) { throw new ArgumentNullException(nameof(jenkinsProvider)); } if (bitriseProvider == null) { throw new ArgumentNullException(nameof(bitriseProvider)); } if (travisCIProvider == null) { throw new ArgumentNullException(nameof(travisCIProvider)); } if (bitbucketPipelinesProvider == null) { throw new ArgumentNullException(nameof(bitbucketPipelinesProvider)); } if (goCDProvider == null) { throw new ArgumentNullException(nameof(goCDProvider)); } if (gitlabCIProvider == null) { throw new ArgumentNullException(nameof(gitlabCIProvider)); } if (tfBuildProvider == null) { throw new ArgumentNullException(nameof(tfBuildProvider)); } AppVeyor = appVeyorProvider; TeamCity = teamCityProvider; MyGet = myGetProvider; Bamboo = bambooProvider; ContinuaCI = continuaCIProvider; Jenkins = jenkinsProvider; Bitrise = bitriseProvider; TravisCI = travisCIProvider; BitbucketPipelines = bitbucketPipelinesProvider; GoCD = goCDProvider; GitLabCI = gitlabCIProvider; TFBuild = tfBuildProvider; Provider = (AppVeyor.IsRunningOnAppVeyor ? BuildProvider.AppVeyor : BuildProvider.Local) | (TeamCity.IsRunningOnTeamCity ? BuildProvider.TeamCity : BuildProvider.Local) | (MyGet.IsRunningOnMyGet ? BuildProvider.MyGet : BuildProvider.Local) | (Bamboo.IsRunningOnBamboo ? BuildProvider.Bamboo : BuildProvider.Local) | (ContinuaCI.IsRunningOnContinuaCI ? BuildProvider.ContinuaCI : BuildProvider.Local) | (Jenkins.IsRunningOnJenkins ? BuildProvider.Jenkins : BuildProvider.Local) | (Bitrise.IsRunningOnBitrise ? BuildProvider.Bitrise : BuildProvider.Local) | (TravisCI.IsRunningOnTravisCI ? BuildProvider.TravisCI : BuildProvider.Local) | (BitbucketPipelines.IsRunningOnBitbucketPipelines ? BuildProvider.BitbucketPipelines : BuildProvider.Local) | (GoCD.IsRunningOnGoCD ? BuildProvider.GoCD : BuildProvider.Local) | (GitLabCI.IsRunningOnGitLabCI ? BuildProvider.GitLabCI : BuildProvider.Local) | (TFBuild.IsRunningOnAzurePipelines ? BuildProvider.AzurePipelines : BuildProvider.Local) | (TFBuild.IsRunningOnAzurePipelinesHosted ? BuildProvider.AzurePipelinesHosted : BuildProvider.Local); IsLocalBuild = Provider == BuildProvider.Local; IsPullRequest = ((Provider & BuildProvider.AppVeyor) != 0 && AppVeyor.Environment.PullRequest.IsPullRequest) || ((Provider & BuildProvider.TeamCity) != 0 && TeamCity.Environment.PullRequest.IsPullRequest) || ((Provider & BuildProvider.Bitrise) != 0 && Bitrise.Environment.PullRequest.IsPullRequest) || ((Provider & BuildProvider.TravisCI) != 0 && TravisCI.Environment.PullRequest.IsPullRequest) || ((Provider & BuildProvider.BitbucketPipelines) != 0 && BitbucketPipelines.Environment.PullRequest.IsPullRequest) || ((Provider & BuildProvider.GitLabCI) != 0 && GitLabCI.Environment.PullRequest.IsPullRequest) || ((Provider & (BuildProvider.AzurePipelines | BuildProvider.AzurePipelinesHosted)) != 0 && TFBuild.Environment.PullRequest.IsPullRequest); }
/// <summary> /// Initializes a new instance of the <see cref="BuildSystem"/> class. /// </summary> /// <param name="appVeyorProvider">The AppVeyor service.</param> public BuildSystem(IAppVeyorProvider appVeyorProvider) { _appVeyorProvider = appVeyorProvider; }
/// <summary> /// Creates a new <see cref="CheckRepositoryInfo"/>. This selects the feeds (a local and/or e remote one) /// and checks the packages that sould actually be produced for them. /// When running on Appveyor, the build number is set. /// </summary> /// <param name="projectsToPublish">The projects to publish.</param> /// <param name="gitInfo">The git info.</param> /// <returns>A new info object.</returns> CheckRepositoryInfo StandardCheckRepository(IEnumerable <SolutionProject> projectsToPublish, SimpleRepositoryInfo gitInfo) { // Local function that displays information for packages already in a feed or not. void DispalyFeedPackageResult(string feedId, IReadOnlyCollection <SolutionProject> missingPackages, int totalCount) { var missingCount = missingPackages.Count; var existCount = totalCount - missingCount; if (missingCount == 0) { Cake.Information($"{feedId}: No packages must be pushed ({existCount} packages already available)."); } else if (existCount == 0) { Cake.Information($"{feedId}: All {missingCount} packages must be pushed."); } else { Cake.Information($"{feedId}: {missingCount} packages must be pushed: {missingPackages.Select( p => p.Name ).Concatenate()}."); Cake.Information($" => {existCount} packages already pushed: {projectsToPublish.Except( missingPackages ).Select( p => p.Name ).Concatenate()}."); } } var result = new CheckRepositoryInfo { Version = gitInfo.SafeNuGetVersion, BuildConfiguration = gitInfo.IsValidRelease && (gitInfo.PreReleaseName.Length == 0 || gitInfo.PreReleaseName == "rc") ? "Release" : "Debug" }; // We build in Debug for any prerelease except "rc": the last prerelease step is in "Release". if (!gitInfo.IsValid) { if (Cake.InteractiveMode() != InteractiveMode.NoInteraction && Cake.ReadInteractiveOption("PublishDirtyRepo", "Repository is not ready to be published. Proceed anyway?", 'Y', 'N') == 'Y') { Cake.Warning("GitInfo is not valid, but you choose to continue..."); result.IgnoreNoPackagesToProduce = true; } else { // On Appveyor, we let the build run: this gracefully handles Pull Requests. if (Cake.AppVeyor().IsRunningOnAppVeyor) { result.IgnoreNoPackagesToProduce = true; } else { Cake.TerminateWithError("Repository is not ready to be published."); } } // When the gitInfo is not valid, we do not try to push any packages, even if the build continues // (either because the user choose to continue or if we are on the CI server). // We don't need to worry about feeds here. } else { // gitInfo is valid: it is either ci or a release build. // Local releases must not be pushed on any remote and are copied to LocalFeed/Local // feed (if LocalFeed/ directory above exists). var isLocalCIRelease = gitInfo.Info.FinalSemVersion.Prerelease.EndsWith(".local"); var localFeed = Cake.FindDirectoryAbove("LocalFeed"); if (localFeed != null && isLocalCIRelease) { localFeed = System.IO.Path.Combine(localFeed, "Local"); System.IO.Directory.CreateDirectory(localFeed); } result.IsLocalCIRelease = isLocalCIRelease; result.LocalFeedPath = localFeed; // Creating the right NuGetRemoteFeed according to the release level. if (!isLocalCIRelease) { if (gitInfo.IsValidRelease) { if (gitInfo.PreReleaseName == "" || gitInfo.PreReleaseName == "prerelease" || gitInfo.PreReleaseName == "rc") { result.RemoteFeed = new MyGetPublicFeed("kuinox-release", "MYGET_RELEASE_API_KEY"); } else { // An alpha, beta, delta, epsilon, gamma, kappa goes to invenietis-preview. result.RemoteFeed = new MyGetPublicFeed("kuinox-preview", "MYGET_PREVIEW_API_KEY"); } } else { Debug.Assert(gitInfo.IsValidCIBuild); result.RemoteFeed = new MyGetPublicFeed("kuinox-ci", "MYGET_CI_API_KEY"); } } } // Now that Local/RemoteFeed are selected, we can check the packages that already exist // in those feeds. if (result.RemoteFeed != null) { using (var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false }, true)) { var requests = projectsToPublish .Select(p => new { Project = p, ExistsAsync = result.RemoteFeed.CheckPackageAsync(Cake, client, p.Name, gitInfo.SafeNuGetVersion) }) .ToList(); System.Threading.Tasks.Task.WaitAll(requests.Select(r => r.ExistsAsync).ToArray()); IEnumerable <SolutionProject> notOk = requests.Where(r => !r.ExistsAsync.Result).Select(r => r.Project); result.RemoteFeed.PackagesToPush.AddRange(notOk); DispalyFeedPackageResult(result.RemoteFeed.PushUrl, result.RemoteFeed.PackagesToPush, requests.Count); // If there is at least a package to push, challenge the key right now: if the key can not be obtained, then // we clear the list. var apiKey = Cake.InteractiveEnvironmentVariable(result.RemoteFeed.APIKeyName); if (string.IsNullOrEmpty(apiKey)) { Cake.Information($"Could not resolve {result.RemoteFeed.APIKeyName}. Push to {result.RemoteFeed.PushUrl} is skipped."); result.RemoteFeed.PackagesToPush.Clear(); } else { result.RemoteFeed.ActualAPIKey = apiKey; } } } if (result.LocalFeedPath != null) { var lookup = projectsToPublish .Select(p => new { Project = p, Path = System.IO.Path.Combine(result.LocalFeedPath, $"{p.Name}.{gitInfo.SafeNuGetVersion}.nupkg") }) .Select(x => new { x.Project, Exists = System.IO.File.Exists(x.Path) }) .ToList(); IEnumerable <SolutionProject> notOk = lookup.Where(r => !r.Exists).Select(r => r.Project); result.LocalFeedPackagesToCopy.AddRange(notOk); DispalyFeedPackageResult(result.LocalFeedPath, result.LocalFeedPackagesToCopy, lookup.Count); } var nbPackagesToPublish = result.ActualPackagesToPublish.Count(); if (nbPackagesToPublish == 0) { Cake.Information($"No packages out of {projectsToPublish.Count()} projects to publish."); if (Cake.Argument("IgnoreNoPackagesToProduce", 'N') == 'Y') { result.IgnoreNoPackagesToProduce = true; } } else { Cake.Information($"Should actually publish {nbPackagesToPublish} out of {projectsToPublish.Count()} projects with version={gitInfo.SafeNuGetVersion} and configuration={result.BuildConfiguration}: {result.ActualPackagesToPublish.Select( p => p.Name ).Concatenate()}"); } IAppVeyorProvider appVeyor = Cake.AppVeyor(); if (appVeyor.IsRunningOnAppVeyor) { if (result.ShouldStop) { appVeyor.UpdateBuildVersion($"{gitInfo.SafeNuGetVersion} - Skipped ({appVeyor.Environment.Build.Number})"); } else { try { appVeyor.UpdateBuildVersion(gitInfo.SafeNuGetVersion); } catch { appVeyor.UpdateBuildVersion($"{gitInfo.SafeNuGetVersion} ({appVeyor.Environment.Build.Number})"); } } } return(result); }
public VersionHelper(ICakeEnvironment environment, ICakeLog log, ICakeArguments arguments, IAppVeyorProvider appVeyorProvider, ITFBuildProvider azureProvider, IGlobber globber, IFileSystem fileSystem, IProcessRunner processRunner, IToolLocator tools) { _environment = environment; _log = log; _arguments = arguments; _appVeyorProvider = appVeyorProvider; _azureProvider = azureProvider; _globber = globber; _fileSystem = fileSystem; _processRunner = processRunner; _tools = tools; if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } Configuration = environment.GetEnvironmentVariable("CONFIGURATION"); if (string.IsNullOrWhiteSpace(Configuration)) { Configuration = _arguments.HasArgument("configuration") ? _arguments.GetArgument("configuration") : "Release"; } string envLogging = environment.GetEnvironmentVariable("LOGGINGLEVEL"); if (!string.IsNullOrWhiteSpace(envLogging)) { Verbosity loggingEnum; if (Enum.TryParse(envLogging, true, out loggingEnum)) { log.Verbosity = loggingEnum; log.Information($"Logging Level: {loggingEnum}", Verbosity.Quiet); if (IsAppVeyor) { _appVeyorProvider.AddInformationalMessage($"Logging set by LoggingLevel enviornment variable to {loggingEnum}"); } _isDefaultLoggingLevel = false; } else { string msg = $"Invalid logging level [{envLogging}]. Use {Verbosity.Quiet}, {Verbosity.Minimal}, {Verbosity.Normal}, {Verbosity.Verbose} or {Verbosity.Diagnostic}"; if (IsAppVeyor) { log.Warning(msg); } _appVeyorProvider.AddWarningMessage(msg); } } else { _isDefaultLoggingLevel = !arguments.HasArgument("verbosity"); } if (_log.Verbosity > Verbosity.Normal) { var environmentVariables = environment.GetEnvironmentVariables(); foreach (string key in environmentVariables.Keys) { log.Verbose($"{key}:{environmentVariables[key]}"); } } CommitMessageMatches = new MatchResult { Success = false }; if (IsAppVeyor) { Branch = _appVeyorProvider.Environment.Repository.Branch; CommitMessageShort = _appVeyorProvider.Environment.Repository.Commit.Message; var match = CommitMessageRegex.Match(_appVeyorProvider.Environment.Repository.Commit.ExtendedMessage); CommitMessageMatches = new MatchResult { Success = match.Success, Groups = match.Groups }; _log.Debug($"Branch:{Branch}"); _log.Debug($"Commit Msg Short:{CommitMessageShort}"); _log.Debug($"Commit Msg Extended:{_appVeyorProvider.Environment.Repository.Commit.ExtendedMessage}"); _log.Debug($"Commit Message Cmd Match:{CommitMessageMatches.Success}"); if (_log.Verbosity >= Verbosity.Verbose && CommitMessageMatches.Success) { _log.Debug("RegEx Group Matches"); foreach (string groupName in CommitMessageRegex.GetGroupNames()) { _log.Debug($"{groupName} : {CommitMessageMatches.Groups[groupName].Value}"); } } } if (IsAzureDevops) { Branch = _azureProvider.Environment.Repository.Branch; //CommitMessageShort = _azureProvider.Environment.Repository.Commit.Message; //var match = CommitMessageRegex.Match(_azureProvider.Environment.Repository.Commit.ExtendedMessage); //CommitMessageMatches = new MatchResult { Success = match.Success, Groups = match.Groups }; //_log.Debug($"Branch:{Branch}"); //_log.Debug($"Commit Msg Short:{CommitMessageShort}"); //_log.Debug($"Commit Msg Extended:{_appVeyorProvider.Environment.Repository.Commit.ExtendedMessage}"); //_log.Debug($"Commit Message Cmd Match:{CommitMessageMatches.Success}"); //if (_log.Verbosity >= Verbosity.Verbose && CommitMessageMatches.Success) //{ // _log.Debug("RegEx Group Matches"); // foreach (string groupName in CommitMessageRegex.GetGroupNames()) // { // _log.Debug($"{groupName} : {CommitMessageMatches.Groups[groupName].Value}"); // } //} } }