Пример #1
0
 public void SetNextVersion(VersionResult version)
 {
     _log.Information($"Building {version.FullVersion}");
     if (IsInteractiveBuild)
     {
         _log.Information($"Interacitve Build Mode");
     }
     else if (IsAppVeyor)
     {
         _appVeyorProvider.UpdateBuildVersion(version.FullVersion);
         _appVeyorProvider.AddInformationalMessage($"Building {version.FullVersion}");
     }
 }
Пример #2
0
        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}");
                //    }
                //}
            }
        }