File tree Expand file tree Collapse file tree 3 files changed +71
-1
lines changed
GitVersionCore.Tests/BuildServers
GitVersionCore/BuildServers Expand file tree Collapse file tree 3 files changed +71
-1
lines changed Original file line number Diff line number Diff line change 1+ namespace GitVersionCore . Tests . BuildServers
2+ {
3+ using System ;
4+ using GitVersion ;
5+ using NUnit . Framework ;
6+ using Shouldly ;
7+
8+ [ TestFixture ]
9+ public class DroneTests : TestBase
10+ {
11+ [ Test ]
12+ public void CanApplyToCurrentContext_ShouldBeTrue_WhenEnvironmentVariableIsSet ( )
13+ {
14+ // Arrange
15+ Environment . SetEnvironmentVariable ( "DRONE" , "true" ) ;
16+ var buildServer = new Drone ( ) ;
17+
18+ // Act
19+ var result = buildServer . CanApplyToCurrentContext ( ) ;
20+
21+ // Assert
22+ result . ShouldBeTrue ( ) ;
23+ }
24+
25+ [ Test ]
26+ public void CanApplyToCurrentContext_ShouldBeFalse_WhenEnvironmentVariableIsNotSet ( )
27+ {
28+ // Arrange
29+ Environment . SetEnvironmentVariable ( "DRONE" , "" ) ;
30+ var buildServer = new Drone ( ) ;
31+
32+ // Act
33+ var result = buildServer . CanApplyToCurrentContext ( ) ;
34+
35+ // Assert
36+ result . ShouldBeFalse ( ) ;
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 1- namespace GitVersion
1+ namespace GitVersion
22{
33 using System ;
44 using System . Collections . Generic ;
@@ -16,6 +16,7 @@ public static class BuildServerList
1616 new VsoAgent ( ) ,
1717 new TravisCI ( ) ,
1818 new EnvRun ( ) ,
19+ new Drone ( )
1920 } ;
2021
2122 public static IEnumerable < IBuildServer > GetApplicableBuildServers ( )
Original file line number Diff line number Diff line change 1+ namespace GitVersion
2+ {
3+ using System ;
4+
5+ public class Drone : BuildServerBase
6+ {
7+ public override bool CanApplyToCurrentContext ( )
8+ {
9+ return Environment . GetEnvironmentVariable ( "DRONE" ) ? . Equals ( "true" , StringComparison . OrdinalIgnoreCase ) ?? false ;
10+ }
11+
12+ public override string GenerateSetVersionMessage ( VersionVariables variables )
13+ {
14+ return variables . FullSemVer ;
15+ }
16+
17+ public override string [ ] GenerateSetParameterMessage ( string name , string value )
18+ {
19+ return new [ ]
20+ {
21+ $ "GitVersion_{ name } ={ value } "
22+ } ;
23+ }
24+
25+ public override string GetCurrentBranch ( bool usingDynamicRepos )
26+ {
27+ return Environment . GetEnvironmentVariable ( "DRONE_BRANCH" ) ;
28+ }
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments