public TemporarySolutionFile( ICakeContext ctx, FilePath originalPath )
 {
     _cake = ctx;
     _originalPath = ctx.MakeAbsolute( originalPath );
     _modifiedPath = _originalPath + Guid.NewGuid().ToString( "N" ) + ".sln";
     ctx.CopyFile( _originalPath, _modifiedPath );
 }
        public void BuildArguments(ICakeContext context, ProcessArgumentBuilder builder)
        {
            if (NoGraphics)
            {
                builder.Append("-nographics");
            }

            builder.Append(PlatformTarget == UnityPlatformTarget.x64 ? "-buildWindows64Player" : "-buildWindowsPlayer");
            builder.AppendQuoted(_outputPath.MakeAbsolute(context.Environment).FullPath);
        }
                public void Should_Throw_If_No_Process_Was_Returned_From_Process_Runner(
                    ICakeContext context, IAdvProcessRunner runner)
                {
                    // Arrange
                    runner.Start(Arg.Any<FilePath>(), Arg.Any<AdvProcessSettings>())
                        .Returns((IAdvProcess) null);

                    Action sut = () => context.StartAdvProcess("hello.exe", runner);

                    // Act / Assert
                    sut.ShouldThrow<CakeException>().WithMessage("Could not start process.");
                }
Beispiel #4
0
        private static GitterChatMessageResult PostToIncomingWebHook(ICakeContext context, string message, GitterChatMessageSettings messageSettings)
        {
            context.Verbose("Posting to incoming webhook {0}...", string.Concat(messageSettings.IncomingWebHookUrl.TrimEnd('/').Reverse().SkipWhile(c => c != '/').Reverse()));

            var gitterWebHookService = new WebhookService();
            var result = gitterWebHookService.PostAsync(messageSettings.IncomingWebHookUrl, message, messageSettings.MessageLevel == GitterMessageLevel.Error ? MessageLevel.Error : MessageLevel.Info);

            var parsedResult = new GitterChatMessageResult(result.Result, DateTime.UtcNow.ToString("u"), string.Empty);

            context.Debug("Result parsed: {0}", parsedResult);

            return parsedResult;
        }
                public void Should_Return_Process_Created_By_Runner(ICakeContext context,
                    FilePath filePath, AdvProcessSettings settings, IAdvProcessRunner runner,
                    IAdvProcess expectedResult)
                {
                    runner.Start(filePath, settings).Returns(expectedResult);

                    Func<IAdvProcess> sut =
                        () => context.StartAdvProcess(filePath, settings, runner);

                    var result = sut();

                    result.Should().BeSameAs(expectedResult);
                }
        /// <summary>
        /// Filters binaries that are in common with orchard web project binaries.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="moduleBinaries">Collection of binaries.</param>
        /// <param name="orchardWebBinaries">Collection of Orchard.Web project binaries.</param>
        /// <returns>Collection of binaries that are shared.</returns>
        public static FilePathCollection Filter(ICakeContext context, FilePathCollection moduleBinaries, FilePathCollection orchardWebBinaries) {
            if (context == null) {
                throw new ArgumentNullException(nameof(context));
            }
            if (moduleBinaries == null || orchardWebBinaries == null) {
                throw new ArgumentNullException("A FilePathCollection is empty.");
            }

            var orchardWebAssemblies = new HashSet<string>(
                orchardWebBinaries.Select(item => item.ToString()),
                StringComparer.InvariantCultureIgnoreCase);

            return new FilePathCollection(moduleBinaries
                .Where(item => orchardWebAssemblies.Contains(item.ToString())), PathComparer.Default);
        }
                public void Should_Use_Environments_Working_Directory(ICakeContext context,
                    IAdvProcessRunner runner)
                {
                    // Arrange
                    context.Environment.WorkingDirectory.Returns(new DirectoryPath("/Working"));

                    Action sut = () => context.StartAdvProcess("hello.exe", runner);

                    // Act
                    sut();

                    // Assert
                    runner.Received(1).Start(Arg.Any<FilePath>(), Arg.Is<AdvProcessSettings>(info =>
                        info.WorkingDirectory.FullPath == "/Working"));
                }
        private static void ValidateFile(ICakeContext context, FilePath file) {
            context.Log.Information("Validating \"{0}\"", file.ToString());

            var errors = new Validator(file).Validate();

            if (errors.Any()) {
                foreach (var error in errors) {
                    context.Log.Error("{0}, LineNumber {1}, FileName {2}", error.Message, error.LineNumber,
                        error.FileName);
                }
            }
            else {
                context.Log.Information("Project file \"{0}\" is valid", file.ToString());
            }
        }
        public FakeCakeContext ()
        {
            testsDir = new DirectoryPath (
                System.IO.Path.GetFullPath (AppDomain.CurrentDomain.BaseDirectory));
            
            var fileSystem = new FileSystem ();
            var environment = new CakeEnvironment ();
            var globber = new Globber (fileSystem, environment);
            log = new FakeLog ();
            var args = new FakeCakeArguments ();
            var processRunner = new ProcessRunner (environment, log);
            var registry = new WindowsRegistry ();

            context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry);
            context.Environment.WorkingDirectory = testsDir;
        }
Beispiel #10
0
 public FakeCakeContext ()
 {
     testsDir = new DirectoryPath (
         System.IO.Path.GetFullPath (AppDomain.CurrentDomain.BaseDirectory));
     
     var fileSystem = new FileSystem ();
     var environment = new CakeEnvironment (new CakePlatform (), new CakeRuntime ());
     var globber = new Globber (fileSystem, environment);
     log = new FakeLog ();
     var args = new FakeCakeArguments ();
     var processRunner = new ProcessRunner (environment, log);
     var registry = new WindowsRegistry ();
     var toolRepo = new ToolRepository (environment);
     var config = new Core.Configuration.CakeConfigurationProvider (fileSystem, environment).CreateConfiguration (testsDir, new Dictionary<string, string> ());
     var toolResolutionStrategy = new ToolResolutionStrategy (fileSystem, environment, globber, config);
     var toolLocator = new ToolLocator (environment, toolRepo, toolResolutionStrategy);
     context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry, toolLocator);
     context.Environment.WorkingDirectory = testsDir;
 }
Beispiel #11
0
        public FakeCakeContext ()
        {
            testsDir = new DirectoryPath (
                System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location));

            var fileSystem = new FileSystem ();
            var environment = new CakeEnvironment ();
            var globber = new Globber (fileSystem, environment);
            log = new FakeLog ();
            var args = new FakeCakeArguments ();
            var processRunner = new ProcessRunner (environment, log);
            var registry = new WindowsRegistry ();
            var toolRepo = new ToolRepository (environment);
            var config = new Core.Configuration.CakeConfigurationProvider (fileSystem, environment).CreateConfiguration (new Dictionary<string, string> ());
            var toolResStrat = new ToolResolutionStrategy (fileSystem, environment, globber, config);
            var toolLocator = new ToolLocator (environment, toolRepo, toolResStrat);

            context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry, toolLocator);
            context.Environment.WorkingDirectory = testsDir;
        }
        /// <summary>
        /// Validates module and theme project files.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="files">Project files to be validated.</param>
        public static void ValidateFiles(ICakeContext context, FilePathCollection files) {
            if (context == null) {
                throw new ArgumentNullException(nameof(context));
            }
            if (files == null) {
                throw new ArgumentNullException(nameof(files));
            }

            if (files.Count == 0) {
                context.Log.Verbose("There are not any files in the collection.");
                return;
            }

            foreach (var file in files) {
                try {
                    ValidateFile(context, file);
                }
                catch (Exception) {
                    context.Log.Verbose("Error validating project file \"{0}\"", file.ToString());
                }
            }
        }
Beispiel #13
0
 public static void DotNetCoreRestore(this ICakeContext context, DotNetCoreRestoreSettings settings)
 {
     context.DotNetCoreRestore(null, settings);
 }
Beispiel #14
0
 public static void DotNetCoreRestore(this ICakeContext context, string root)
 {
     context.DotNetCoreRestore(root, null);
 }
        private static async Task <bool> WaitForPipelineToFinishAsync(int projectId, Pipeline pipeline, ICakeContext context)
        {
            var pipelineIsRunning = true;

            while (pipelineIsRunning)
            {
                await Task.Delay(15000);

                Console.WriteLine("Checking pipeline status...");
                pipeline = await GetPipelineAsync(projectId, pipeline.Id);

                switch (pipeline.Status)
                {
                case "success":
                    pipelineIsRunning = false;
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Pipeline succeeded");
                    break;

                case "failed":
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Pipeline failed");
                    return(false);

                case "canceled":
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Pipeline was cancelled");
                    return(false);

                case "skipped":
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Pipeline was skipped");
                    return(false);

                default:
                    continue;
                }
            }

            return(true);
        }
Beispiel #16
0
 /// <summary>
 /// Always create a <see cref="DNXRuntimeInformation"/> object that may be not valid.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 static DNXRuntimeInformation LoadDNXRuntimeInformation( ICakeContext context )
 {
     var output = new List<string>();
     if( RunCmdAliases.RunCmd( context, "where dnx", output.Add ) != 0 ) return new DNXRuntimeInformation( null );
     return new DNXRuntimeInformation( output[0] );
 }
Beispiel #17
0
 public static void DotNetCoreTest(this ICakeContext context, string project)
 {
     context.DotNetCoreTest(project, null);
 }
Beispiel #18
0
 public static string PropertyAliasReturningCachedString(this ICakeContext context)
 {
     return("Hello World");
 }
Beispiel #19
0
 public static void DownloadFile(this ICakeContext context, string address, FilePath outputPath, DownloadFileSettings settings)
 {
     DownloadFile(context, new Uri(address), outputPath, settings);
 }
Beispiel #20
0
 public static string Prompt(this ICakeContext context, string message, string defaultResult)
 {
     return(Prompt(context, message, defaultResult, TimeSpan.FromSeconds(30)));
 }
        // ---------------- Constructor ----------------

        public FilePathArgumentBinder(ICakeContext cakeContext) :
            base(cakeContext)
        {
        }
Beispiel #22
0
 public static string Prompt(this ICakeContext context, string message)
 {
     return(Prompt(context, message, defaultResult: null));
 }
Beispiel #23
0
 public static string Prompt(this ICakeContext context, string message, TimeSpan timeout)
 {
     return(Prompt(context, message, null, timeout));
 }
Beispiel #24
0
 public OpenCoverContext(ICakeContext context)
 {
     _context = context;
     Log      = new NullLog();
     _runner  = new OpenCoverProcessRunner();
 }
 public static void SoftNUnit3(this ICakeContext context, IEnumerable <FilePath> assemblies)
 {
     context.SoftNUnit3(assemblies, new NUnit3Settings());
 }
Beispiel #26
0
 public static void DotNetCoreExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments)
 {
     context.DotNetCoreExecute(assemblyPath, arguments, null);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 public BuildScriptHost(
     ICakeEngine engine,
     ICakeContext context )
     : base(engine, context)
 {
 }
Beispiel #28
0
 internal static string[] ToRelativePathStrings(this IEnumerable<FilePath> filePaths, ICakeContext context, DirectoryPath repositoryDirectoryPath)
 {
     return filePaths
         .Select(filePath => filePath.MakeRelativePath(context.Environment, repositoryDirectoryPath).FullPath)
         .ToArray();
 }
Beispiel #29
0
 public static int PropertyAliasReturningInteger(this ICakeContext context)
 {
     return(42);
 }
Beispiel #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SlackProvider"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public SlackProvider(ICakeContext context)
 {
     _chat = new SlackChatProvider(context);
 }
Beispiel #31
0
 public static bool PropertyAliasReturningCachedBoolean(this ICakeContext context)
 {
     return(true);
 }
Beispiel #32
0
 public static void DotNetCoreExecute(this ICakeContext context, FilePath assemblyPath)
 {
     context.DotNetCoreExecute(assemblyPath, null);
 }
        /// <summary>
        /// Sends an email via the SendGrid API, based on the provided settings
        /// </summary>
        /// <param name="context">The Cake Context</param>
        /// <param name="senderName">The name of the person sending the email</param>
        /// <param name="senderAddress">The email address of the person sending the email</param>
        /// <param name="recipients">An enumeration of recipients who will receive the email</param>
        /// <param name="subject">The subject line of the email</param>
        /// <param name="htmlContent">The HTML content</param>
        /// <param name="textContent">The text content</param>
        /// <param name="attachments">Attachments to send with the email</param>
        /// <param name="settings">The settings to be used when sending the email</param>
        /// <returns>An instance of <see cref="SendGridResult"/> indicating success/failure</returns>
        internal static SendGridResult SendEmail(this ICakeContext context, string senderName, string senderAddress, IEnumerable <System.Net.Mail.MailAddress> recipients, string subject, string htmlContent, string textContent, IEnumerable <System.Net.Mail.AttachmentBase> attachments, SendGridSettings settings)
        {
            if (recipients == null)
            {
                throw new CakeException("You must specify at least one recipient");
            }

            var safeRecipients = recipients.Where(r => r != null && !string.IsNullOrEmpty(r.Address));

            if (!safeRecipients.Any())
            {
                throw new CakeException("None of the recipients you specified have an email address");
            }

            if (attachments == null)
            {
                attachments = Enumerable.Empty <System.Net.Mail.AttachmentBase>();
            }

            try
            {
                using (var client = new Client(settings.ApiKey))
                {
                    context.Verbose("Sending email to {0} via the SendGrid API...", string.Join(", ", safeRecipients.Select(r => r.Address).ToArray()));

                    var from             = new MailAddress(senderAddress, senderName);
                    var personalizations = safeRecipients.Select(r => new MailPersonalization {
                        To = new[] { new MailAddress(r.Address, r.DisplayName) }
                    }).ToArray();
                    var contents = new[]
                    {
                        new MailContent("text/plain", textContent),
                        new MailContent("text/html", htmlContent)
                    };
                    var trackingSettings = new TrackingSettings
                    {
                        ClickTracking = new ClickTrackingSettings
                        {
                            EnabledInHtmlContent = false,
                            EnabledInTextContent = false
                        },
                        OpenTracking = new OpenTrackingSettings {
                            Enabled = false
                        },
                        GoogleAnalytics = new GoogleAnalyticsSettings {
                            Enabled = false
                        },
                        SubscriptionTracking = null
                    };

                    var sendGridAttachments = attachments
                                              .Select(a =>
                    {
                        var buffer = (byte[])null;
                        using (var ms = new MemoryStream())
                        {
                            a.ContentStream.CopyTo(ms);
                            buffer = ms.ToArray();
                        }

                        return(new StrongGrid.Model.Attachment()
                        {
                            Content = Convert.ToBase64String(buffer),
                            ContentId = a.ContentId,
                            Disposition = a is System.Net.Mail.LinkedResource ? "inline" : "attachment",
                            FileName = a.ContentType.Name,
                            Type = a.ContentType.MediaType
                        });
                    }).ToArray();

                    client.Mail.SendAsync(personalizations, subject, contents, from, null, sendGridAttachments, null, null, null, null, null, null, null, null, null, null, trackingSettings).Wait();
                }

                return(new SendGridResult(true, DateTime.UtcNow.ToString("u"), string.Empty));
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }

                if (settings.ThrowOnFail.HasValue && settings.ThrowOnFail.Value)
                {
                    throw new CakeException(e.Message);
                }
                else
                {
                    return(new SendGridResult(false, DateTime.UtcNow.ToString("u"), e.Message));
                }
            }
        }
Beispiel #34
0
 public static void DotNetCoreRun(this ICakeContext context, string project, ProcessArgumentBuilder arguments)
 {
     context.DotNetCoreRun(project, arguments, null);
 }
 public void PerformSetup(Action <ICakeContext> action, ICakeContext context)
 {
 }
Beispiel #36
0
 public static void DotNetCoreTest(this ICakeContext context)
 {
     context.DotNetCoreTest(null, null);
 }
Beispiel #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GitterProvider"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public GitterProvider(ICakeContext context)
 {
     _chat = new GitterChatProvider(context);
 }
Beispiel #38
0
 public ShowUnitRunner(ICakeContext context) : base(context)
 {
 }
Beispiel #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GitterChatProvider"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public GitterChatProvider(ICakeContext context)
 {
     _context = context;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TreeScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 /// <param name="console">The console.</param>
 public TreeScriptHost(ICakeEngine engine, ICakeContext context, IConsole console)
     : base(engine, context)
 {
     _console = console ?? throw new ArgumentNullException(nameof(console));
 }
                public void Should_Make_Working_Directory_Absolute_If_Set_To_Relative(
                    ICakeContext context,
                    [NoAutoProperties] AdvProcessSettings settings, IAdvProcessRunner runner)
                {
                    // Arrange
                    context.Environment.WorkingDirectory.Returns("/Working");
                    settings.WorkingDirectory = "OtherWorking";

                    Action sut =
                        () => context.StartAdvProcess("hello.exe", settings, runner);

                    // Act
                    sut();

                    // Assert
                    runner.Received(1).Start(
                        Arg.Any<FilePath>(),
                        Arg.Is<AdvProcessSettings>(info =>
                            info.WorkingDirectory.FullPath == "/Working/OtherWorking"));
                }
Beispiel #42
0
        public static ICollection <GitDiffFile> GitDiff(
            this ICakeContext context,
            DirectoryPath repositoryDirectoryPath,
            string sinceCommitId,
            string toCommitId
            )
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (repositoryDirectoryPath == null)
            {
                throw new ArgumentNullException(nameof(repositoryDirectoryPath));
            }

            if (string.IsNullOrWhiteSpace(sinceCommitId))
            {
                throw new ArgumentNullException(nameof(sinceCommitId));
            }

            return(context.UseRepository(
                       repositoryDirectoryPath,
                       repository =>
            {
                var initalCommit = new List <KeyValuePair <Tree, Tree> >();
                if (sinceCommitId == Git.GitCommit.RootCommit)
                {
                    var firstCommit = repository.Commits.Select(commit => commit).FirstOrDefault();
                    if (firstCommit == null)
                    {
                        return new GitDiffFile[0];
                    }
                    initalCommit.Add(
                        new KeyValuePair <Tree, Tree>(
                            repository.ObjectDatabase.CreateTree(new TreeDefinition()),
                            firstCommit.Tree
                            )
                        );
                    sinceCommitId = firstCommit.Sha;
                }

                if (!string.IsNullOrWhiteSpace(toCommitId))
                {
                    var fromCommitTree = sinceCommitId == Git.GitCommit.RootCommit
                                ? repository.ObjectDatabase.CreateTree(new TreeDefinition())
                                : repository.Lookup <Commit>(sinceCommitId)?.Tree;
                    var toCommitTree = repository.Lookup <Commit>(toCommitId)?.Tree;
                    return (
                        from change in repository.Diff.Compare <TreeChanges>(fromCommitTree, toCommitTree)
                        select new GitDiffFile(change)
                        ).ToArray();
                }

                return (
                    from trees in initalCommit.Concat(
                        from commit in repository.Commits.QueryBy(new CommitFilter
                {
                    SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Time,
                    IncludeReachableFrom = sinceCommitId,
                    ExcludeReachableFrom = repository.Lookup <Commit>(sinceCommitId)?.Parents
                }) as IEnumerable <Commit> ?? new Commit[0]
                        from parent in commit.Parents
                        select new KeyValuePair <Tree, Tree>(parent.Tree, commit.Tree)
                        )
                    from change in repository.Diff.Compare <TreeChanges>(trees.Key, trees.Value)
                    select new GitDiffFile(change)
                    ).ToArray();
            }
                       ));
            //}
            //return context.UseRepository(
            //    repositoryDirectoryPath,
            //    repository => (
            //        from commit in repository.Commits.QueryBy(new CommitFilter
            //        {
            //            SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Time,
            //            IncludeReachableFrom = sinceCommitId,
            //            ExcludeReachableFrom = repository.Lookup<Commit>(sinceCommitId)?.Parents
            //        }) as IEnumerable<Commit> ?? new Commit[0]
            //        from parent in commit.Parents
            //        from change in repository.Diff.Compare<TreeChanges>(parent.Tree, commit.Tree)
            //        select new GitDiffFile(change)
            //        ).ToList());
        }
                public void Should_Use_Provided_Working_Directory_If_Set(ICakeContext context,
                    [NoAutoProperties] AdvProcessSettings settings, IAdvProcessRunner runner)
                {
                    // Arrange
                    settings.WorkingDirectory = "/OtherWorking";

                    Action sut =
                        () => context.StartAdvProcess("hello.exe", settings, runner);

                    // Act
                    sut();

                    // Assert
                    runner.Received(1).Start(
                        Arg.Any<FilePath>(),
                        Arg.Is<AdvProcessSettings>(info =>
                            info.WorkingDirectory.FullPath == "/OtherWorking"));
                }
Beispiel #44
0
 public static void Configure(ICakeContext context,
                              IReadOnlyList <ICakeTaskInfo> tasks)
 {
     Tasks   = tasks;
     Context = context;
 }
Beispiel #45
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KuduProvider"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        internal KuduProvider(ICakeContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var environmenVariables = context.EnvironmentVariables();
            Deployment = new Deployment(environmenVariables);
            WebSite = new WebSite(environmenVariables);
            SCM = new SCM(environmenVariables);
            Tools = new Tools(environmenVariables);
            AppSettings = environmenVariables
                .Where(key => key.Key.StartsWith("APPSETTING_"))
                .ToDictionary(
                    key => string.Concat(key.Key.Skip(11)),
                    value => value.Value
                );
            ConnectionStrings = environmenVariables
                .Where(key => key.Key.StartsWith("SQLAZURECONNSTR_"))
                .ToDictionary(
                    key => string.Concat(key.Key.Skip(16)),
                    value => value.Value
                );
            IsRunningOnKudu = !string.IsNullOrWhiteSpace(WebSite.Name);


            _kuduSyncRunner = new KuduSyncRunner(context.FileSystem, context.Environment, context.Globber, context.ProcessRunner);
        }
 public Logger( ICakeContext ctx )
 {
     _ctx = ctx;
 }
Beispiel #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:SvnAdd"/> class.
 /// </summary>
 public SvnAdd(ICakeContext context) : base(context)
 {
     base.Command        = "add";
     base.NonInteractive = true;
     base.NoAuthCache    = true;
 }
        private static async Task <bool> WaitForJobToFinishAsync(int projectId, long jobId, ICakeContext context)
        {
            var jobIsRunning = true;

            while (jobIsRunning)
            {
                await Task.Delay(15000);

                Console.WriteLine("Checking job status...");
                var job = await GetJobAsync(projectId, jobId);

                switch (job.Status)
                {
                case "success":
                    jobIsRunning = false;
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Job succeeded");
                    break;

                case "failed":
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Job failed");
                    return(false);

                case "canceled":
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Job was cancelled");
                    return(false);

                case "skipped":
                    context?.Log.Write(Verbosity.Normal, LogLevel.Information, "Job was skipped");
                    return(false);

                default:
                    continue;
                }
            }

            return(true);
        }
Beispiel #49
0
 public static void NotAScriptMethod(this ICakeContext context)
 {
 }
Beispiel #50
0
 // ReSharper disable once UnusedTypeParameter
 public static void GenericScriptMethod <T>(this ICakeContext context)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SlackChatProvider"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public SlackChatProvider(ICakeContext context)
 {
     _context = context;
 }
Beispiel #52
0
 public static void PropertyAliasWithMoreThanOneMethod(this ICakeContext context, int number)
 {
 }
Beispiel #53
0
        private static SlackChatMessageResult PostToIncomingWebHook(
            ICakeContext context,
            string channel,
            string text,
            SlackChatMessageSettings messageSettings
            )
        {
            if (messageSettings == null)
            {
                throw new ArgumentNullException("messageSettings", "Invalid slack message specified");
            }

            if (string.IsNullOrWhiteSpace(messageSettings.IncomingWebHookUrl))
            {
                throw new NullReferenceException("Invalid IncomingWebHookUrl supplied.");
            }


            context.Verbose(
                "Posting to incoming webhook {0}...",
                string.Concat(
                    messageSettings
                        .IncomingWebHookUrl
                        .TrimEnd('/')
                        .Reverse()
                        .SkipWhile(c => c != '/')
                        .Reverse()
                    )
                );

            var postJson = JsonMapper.ToJson(
                new
                {
                    channel,
                    text,
                    username = messageSettings.UserName ?? "CakeBuild",
                    icon_url =
                        messageSettings.IconUrl != null
                            ? messageSettings.IconUrl.AbsoluteUri
                            : "https://raw.githubusercontent.com/cake-build/graphics/master/png/cake-small.png"
                }
                );

           context.Debug("Parameter: {0}", postJson);

            using (var client = new WebClient())
            {
                var postBytes = Encoding.UTF8.GetBytes(postJson);
                
                var resultBytes = client.UploadData(
                        messageSettings.IncomingWebHookUrl,
                        "POST",
                        postBytes
                        );

                var result = Encoding.UTF8.GetString(
                    resultBytes
                    );

                var parsedResult = new SlackChatMessageResult(
                    StringComparer.OrdinalIgnoreCase.Equals(result, "ok"),
                    channel,
                    string.Empty,
                    StringComparer.OrdinalIgnoreCase.Equals(result, "ok") ? string.Empty : result
                    );

                context.Debug("Result parsed: {0}", parsedResult);
                return parsedResult;
            }
        }
Beispiel #54
0
 public static void PropertyAliasReturningVoid(this ICakeContext context)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CakeMSBuildEngine"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public CakeMSBuildEngine(ICakeContext context)
 {
     this.context = context;
 }
 public Ef6AliasesFacts()
 {
     _context = Substitute.For<ICakeContext>();
 }