Skip to content

Commit

Permalink
Merge branch 'devlead-feature/GH-1241' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
patriksvensson committed Sep 28, 2016
2 parents 554af87 + a27264a commit 0547019
Show file tree
Hide file tree
Showing 4 changed files with 591 additions and 6 deletions.
184 changes: 178 additions & 6 deletions src/Cake.Common/Build/AppVeyor/AppVeyorProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,32 @@ public sealed class AppVeyorProvider : IAppVeyorProvider
/// <value>
/// <c>true</c> if the current build is running on AppVeyor.; otherwise, <c>false</c>.
/// </value>
/// <para>Via BuildSystem</para>
/// <example>
/// <code>
/// if (BuildSystem.AppVeyor.IsRunningOnAppVeyor)
/// {
/// Information("Running on AppVeyor");
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
/// <para>Via AppVeyor</para>
/// <example>
/// <code>
/// if (AppVeyor.IsRunningOnAppVeyor)
/// {
/// Information("Running on AppVeyor");
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
public bool IsRunningOnAppVeyor => !string.IsNullOrWhiteSpace(_environment.GetEnvironmentVariable("APPVEYOR"));

/// <summary>
Expand All @@ -37,6 +63,60 @@ public sealed class AppVeyorProvider : IAppVeyorProvider
/// <value>
/// The AppVeyor environment.
/// </value>
/// <para>Via BuildSystem</para>
/// <example>
/// <code>
/// if (BuildSystem.AppVeyor.IsRunningOnAppVeyor)
/// {
/// Information(
/// @"Environment:
/// ApiUrl: {0}
/// Configuration: {1}
/// JobId: {2}
/// JobName: {3}
/// Platform: {4}
/// ScheduledBuild: {5}",
/// BuildSystem.AppVeyor.Environment.ApiUrl,
/// BuildSystem.AppVeyor.Environment.Configuration,
/// BuildSystem.AppVeyor.Environment.JobId,
/// BuildSystem.AppVeyor.Environment.JobName,
/// BuildSystem.AppVeyor.Environment.Platform,
/// BuildSystem.AppVeyor.Environment.ScheduledBuild
/// );
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
/// <para>Via AppVeyor</para>
/// <example>
/// <code>
/// if (AppVeyor.IsRunningOnAppVeyor)
/// {
/// Information(
/// @"Environment:
/// ApiUrl: {0}
/// Configuration: {1}
/// JobId: {2}
/// JobName: {3}
/// Platform: {4}
/// ScheduledBuild: {5}",
/// AppVeyor.Environment.ApiUrl,
/// AppVeyor.Environment.Configuration,
/// AppVeyor.Environment.JobId,
/// AppVeyor.Environment.JobName,
/// AppVeyor.Environment.Platform,
/// AppVeyor.Environment.ScheduledBuild
/// );
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
public AppVeyorEnvironmentInfo Environment { get; }

/// <summary>
Expand Down Expand Up @@ -114,8 +194,7 @@ public void UploadArtifact(FilePath path, AppVeyorUploadArtifactsSettings settin
arguments.AppendQuoted(settings.DeploymentName);
}

// Start the process.
_processRunner.Start("appveyor", new ProcessSettings { Arguments = arguments });
StartAppVeyor(arguments);
}

/// <summary>
Expand Down Expand Up @@ -177,6 +256,32 @@ public void UploadTestResults(FilePath path, AppVeyorTestResultsType resultsType
/// Updates the build version.
/// </summary>
/// <param name="version">The new build version.</param>
/// <para>Via BuildSystem</para>
/// <example>
/// <code>
/// if (BuildSystem.AppVeyor.IsRunningOnAppVeyor)
/// {
/// BuildSystem.AppVeyor.UpdateBuildVersion("2.0.0.0");
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
/// <para>Via AppVeyor</para>
/// <example>
/// <code>
/// if (AppVeyor.IsRunningOnAppVeyor)
/// {
/// AppVeyor.UpdateBuildVersion("2.0.0.0");
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
public void UpdateBuildVersion(string version)
{
if (version == null)
Expand All @@ -199,8 +304,7 @@ public void UpdateBuildVersion(string version)
arguments.Append("-Version");
arguments.AppendQuoted(version);

// Start the process.
_processRunner.Start("appveyor", new ProcessSettings { Arguments = arguments });
StartAppVeyor(arguments);
}

/// <summary>
Expand All @@ -209,6 +313,64 @@ public void UpdateBuildVersion(string version)
/// <param name="message">A short message to display</param>
/// <param name="category">The category of the message</param>
/// <param name="details">Additional message details</param>
/// <para>Via BuildSystem</para>
/// <example>
/// <code>
/// if (BuildSystem.AppVeyor.IsRunningOnAppVeyor)
/// {
/// BuildSystem.AppVeyor.AddMessage(
/// "This is a error message.",
/// AppVeyorMessageCategoryType.Error,
/// "Error details."
/// );
///
/// BuildSystem.AppVeyor.AddMessage(
/// "This is a information message.",
/// AppVeyorMessageCategoryType.Information,
/// "Information details."
/// );
///
/// BuildSystem.AppVeyor.AddMessage(
/// "This is a warning message.",
/// AppVeyorMessageCategoryType.Warning,
/// "Warning details."
/// );
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
/// <para>Via AppVeyor</para>
/// <example>
/// <code>
/// if (AppVeyor.IsRunningOnAppVeyor)
/// {
/// AppVeyor.AddMessage(
/// "This is a error message.",
/// AppVeyorMessageCategoryType.Error,
/// "Error details."
/// );
///
/// AppVeyor.AddMessage(
/// "This is a information message.",
/// AppVeyorMessageCategoryType.Information,
/// "Information details."
/// );
///
/// AppVeyor.AddMessage(
/// "This is a warning message.",
/// AppVeyorMessageCategoryType.Warning,
/// "Warning details."
/// );
/// }
/// else
/// {
/// Information("Not running on AppVeyor");
/// }
/// </code>
/// </example>
public void AddMessage(string message, AppVeyorMessageCategoryType category = AppVeyorMessageCategoryType.Information, string details = null)
{
if (message == null)
Expand Down Expand Up @@ -238,8 +400,18 @@ public void AddMessage(string message, AppVeyorMessageCategoryType category = Ap
arguments.AppendQuoted(details);
}

// Start the process.
_processRunner.Start("appveyor", new ProcessSettings { Arguments = arguments });
StartAppVeyor(arguments);
}

private void StartAppVeyor(ProcessArgumentBuilder arguments, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
{
var process = _processRunner.Start("appveyor", new ProcessSettings { Arguments = arguments });
process.WaitForExit();
var exitCode = process.GetExitCode();
if (exitCode != 0)
{
throw new CakeException($"{memberName} failed ({exitCode}).");
}
}
}
}
Loading

0 comments on commit 0547019

Please sign in to comment.