Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add support for drone
  • Loading branch information
Vadim Hatsura committed May 13, 2019
commit abbcee4c710969206f0ddb6091d6f70e0dfb24de
39 changes: 39 additions & 0 deletions src/GitVersionCore.Tests/BuildServers/DroneTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace GitVersionCore.Tests.BuildServers
{
using System;
using GitVersion;
using NUnit.Framework;
using Shouldly;

[TestFixture]
public class DroneTests : TestBase
{
[Test]
public void CanApplyToCurrentContext_ShouldBeTrue_WhenEnvironmentVariableIsSet()
{
// Arrange
Environment.SetEnvironmentVariable("DRONE", "true");
var buildServer = new Drone();

// Act
var result = buildServer.CanApplyToCurrentContext();

// Assert
result.ShouldBeTrue();
}

[Test]
public void CanApplyToCurrentContext_ShouldBeFalse_WhenEnvironmentVariableIsNotSet()
{
// Arrange
Environment.SetEnvironmentVariable("DRONE", "");
var buildServer = new Drone();

// Act
var result = buildServer.CanApplyToCurrentContext();

// Assert
result.ShouldBeFalse();
}
}
}
3 changes: 2 additions & 1 deletion src/GitVersionCore/BuildServers/BuildServerList.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GitVersion
namespace GitVersion
{
using System;
using System.Collections.Generic;
Expand All @@ -16,6 +16,7 @@ public static class BuildServerList
new VsoAgent(),
new TravisCI(),
new EnvRun(),
new Drone()
};

public static IEnumerable<IBuildServer> GetApplicableBuildServers()
Expand Down
30 changes: 30 additions & 0 deletions src/GitVersionCore/BuildServers/Drone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace GitVersion
{
using System;

public class Drone : BuildServerBase
{
public override bool CanApplyToCurrentContext()
{
return Environment.GetEnvironmentVariable("DRONE")?.Equals("true", StringComparison.OrdinalIgnoreCase) ?? false;
}

public override string GenerateSetVersionMessage(VersionVariables variables)
{
return variables.FullSemVer;
}

public override string[] GenerateSetParameterMessage(string name, string value)
{
return new[]
{
$"GitVersion_{name}={value}"
};
}

public override string GetCurrentBranch(bool usingDynamicRepos)
{
return Environment.GetEnvironmentVariable("DRONE_BRANCH");
}
}
}