diff --git a/.travis.yml b/.travis.yml index d161a6ab8f..7601be96ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ os: - linux - osx before_install: # We need to download nuget.exe due to: https://github.com/travis-ci/travis-ci/issues/5932 + - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags - mkdir -p .nuget - wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - mono .nuget/nuget.exe @@ -14,6 +15,8 @@ install: - mono .nuget/nuget.exe restore src/GitVersion.sln -Verbosity detailed - mono .nuget/nuget.exe install NUnit.Runners -Version 3.2.1 -OutputDirectory ./src/packages script: + - xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed + - mono ./build/NuGetCommandLineBuild/tools/GitVersion.exe -l console -output buildserver -updateAssemblyInfo - xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed - mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --where "cat != NoMono" --noresult @@ -23,4 +26,4 @@ script: # # To run a clean build with Mono, executing all tests, do: # xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "cat != NoMono" --noresult -# \ No newline at end of file +# diff --git a/src/GitVersionCore.Tests/ExecuteCoreTests.cs b/src/GitVersionCore.Tests/ExecuteCoreTests.cs index ab4b43d98f..85852b6a3c 100644 --- a/src/GitVersionCore.Tests/ExecuteCoreTests.cs +++ b/src/GitVersionCore.Tests/ExecuteCoreTests.cs @@ -141,7 +141,8 @@ public void DynamicRepositoriesShouldNotErrorWithFailedToFindGitDirectory() string RepositoryScope(ExecuteCore executeCore = null, Action fixtureAction = null) { // Make sure GitVersion doesn't trigger build server mode when we are running the tests - Environment.SetEnvironmentVariable("APPVEYOR", null); + Environment.SetEnvironmentVariable(AppVeyor.EnvironmentVariableName, null); + Environment.SetEnvironmentVariable(TravisCI.EnvironmentVariableName, null); var infoBuilder = new StringBuilder(); Action infoLogger = s => { diff --git a/src/GitVersionCore/BuildServers/AppVeyor.cs b/src/GitVersionCore/BuildServers/AppVeyor.cs index fb656a909e..63d2a8d456 100644 --- a/src/GitVersionCore/BuildServers/AppVeyor.cs +++ b/src/GitVersionCore/BuildServers/AppVeyor.cs @@ -6,9 +6,11 @@ public class AppVeyor : BuildServerBase { - public override bool CanApplyToCurrentContext() + public const string EnvironmentVariableName = "APPVEYOR"; + + public override bool CanApplyToCurrentContext() { - return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPVEYOR")); + return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(EnvironmentVariableName)); } public override string GenerateSetVersionMessage(VersionVariables variables) diff --git a/src/GitVersionCore/BuildServers/BuildServerList.cs b/src/GitVersionCore/BuildServers/BuildServerList.cs index 45181830e5..5877c3be1a 100644 --- a/src/GitVersionCore/BuildServers/BuildServerList.cs +++ b/src/GitVersionCore/BuildServers/BuildServerList.cs @@ -13,7 +13,8 @@ public static class BuildServerList new MyGet(), new Jenkins(), new GitLabCi(), - new VsoAgent() + new VsoAgent(), + new TravisCI(), }; public static IEnumerable GetApplicableBuildServers() diff --git a/src/GitVersionCore/BuildServers/TeamCity.cs b/src/GitVersionCore/BuildServers/TeamCity.cs index a0515e56f1..3dfd13a1ba 100644 --- a/src/GitVersionCore/BuildServers/TeamCity.cs +++ b/src/GitVersionCore/BuildServers/TeamCity.cs @@ -4,9 +4,11 @@ public class TeamCity : BuildServerBase { - public override bool CanApplyToCurrentContext() + public const string EnvironmentVariableName = "TEAMCITY_VERSION"; + + public override bool CanApplyToCurrentContext() { - return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION")); + return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(EnvironmentVariableName)); } public override string GetCurrentBranch(bool usingDynamicRepos) diff --git a/src/GitVersionCore/BuildServers/TravisCI.cs b/src/GitVersionCore/BuildServers/TravisCI.cs new file mode 100644 index 0000000000..5deed8c6d6 --- /dev/null +++ b/src/GitVersionCore/BuildServers/TravisCI.cs @@ -0,0 +1,32 @@ +using System; +namespace GitVersion +{ + public class TravisCI : BuildServerBase + { + public const string EnvironmentVariableName = "TRAVIS"; + + public override bool CanApplyToCurrentContext () + { + return "true".Equals(Environment.GetEnvironmentVariable(EnvironmentVariableName)) && "true".Equals(Environment.GetEnvironmentVariable("CI")); + } + + public override string GenerateSetVersionMessage(VersionVariables variables) + { + return variables.FullSemVer; + } + + public override string[] GenerateSetParameterMessage(string name, string value) + { + return new[] + { + string.Format("GitVersion_{0}={1}", name, value) + }; + } + + public override bool PreventFetch () + { + return true; + } + } +} + diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 8cec6326d9..6f77c7fa3b 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -165,6 +165,7 @@ + diff --git a/src/GitVersionCore/packages.config b/src/GitVersionCore/packages.config index 8fcd455f6b..ce519f7f9c 100644 --- a/src/GitVersionCore/packages.config +++ b/src/GitVersionCore/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/GitVersionExe.Tests/GitVersionHelper.cs b/src/GitVersionExe.Tests/GitVersionHelper.cs index 0230813db5..2ab6652d13 100644 --- a/src/GitVersionExe.Tests/GitVersionHelper.cs +++ b/src/GitVersionExe.Tests/GitVersionHelper.cs @@ -3,6 +3,7 @@ using System.IO; using System.Text; using GitTools; +using GitVersion; public static class GitVersionHelper { @@ -36,8 +37,9 @@ static ExecutionResults ExecuteIn(ArgumentBuilder arguments) var environmentalVariables = new[] { - new KeyValuePair("TEAMCITY_VERSION", arguments.IsTeamCity ? "8.0.0" : null), - new KeyValuePair("APPVEYOR", null) + new KeyValuePair(TeamCity.EnvironmentVariableName, arguments.IsTeamCity ? "8.0.0" : null), + new KeyValuePair(AppVeyor.EnvironmentVariableName, null), + new KeyValuePair(TravisCI.EnvironmentVariableName, null), }; var exitCode = -1; diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index f80047facd..d013548403 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -135,19 +135,34 @@ ]]> - + mono - + + + + + + + + + + + + + + + + @@ -158,14 +173,7 @@ - - - - - - - - + @@ -175,13 +183,14 @@ - + + @@ -205,6 +214,7 @@ + diff --git a/src/GitVersionExe/packages.config b/src/GitVersionExe/packages.config index bbe3470e94..3574c719e9 100644 --- a/src/GitVersionExe/packages.config +++ b/src/GitVersionExe/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/GitVersionTask/packages.config b/src/GitVersionTask/packages.config index 5251d970be..93b6121f7c 100644 --- a/src/GitVersionTask/packages.config +++ b/src/GitVersionTask/packages.config @@ -1,6 +1,6 @@  - +