Skip to content

Commit 01ebb81

Browse files
authored
Merge pull request #310 from qmfrederik/features/travis
Add Travis CI support
2 parents 6d930a1 + a06a5ef commit 01ebb81

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/NerdBank.GitVersioning/CloudBuild.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static class CloudBuild
1919
new AtlassianBamboo(),
2020
new Jenkins(),
2121
new GitLab(),
22+
new Travis(),
2223
};
2324

2425
/// <summary>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace Nerdbank.GitVersioning.CloudBuildServices
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
7+
/// <summary>
8+
/// Travis CI build support.
9+
/// </summary>
10+
/// <remarks>
11+
/// The Travis CI environment variables referenced here are documented here:
12+
/// https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
13+
/// </remarks>
14+
internal class Travis: ICloudBuild
15+
{
16+
// TRAVIS_BRANCH can reference a branch or a tag, so make sure it starts with refs/heads
17+
public string BuildingBranch => CloudBuild.ShouldStartWith(Environment.GetEnvironmentVariable("TRAVIS_BRANCH"), "refs/heads/");
18+
19+
public string BuildingTag => Environment.GetEnvironmentVariable("TRAVIS_TAG");
20+
21+
public string GitCommitId => Environment.GetEnvironmentVariable("TRAVIS_COMMIT");
22+
23+
public bool IsApplicable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TRAVIS"));
24+
25+
public bool IsPullRequest => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST_BRANCH"));
26+
27+
public IReadOnlyDictionary<string, string> SetCloudBuildNumber(string buildNumber, TextWriter stdout, TextWriter stderr)
28+
{
29+
return new Dictionary<string, string>();
30+
}
31+
32+
public IReadOnlyDictionary<string, string> SetCloudBuildVariable(string name, string value, TextWriter stdout, TextWriter stderr)
33+
{
34+
return new Dictionary<string, string>();
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)