Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Team City #21

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 1 addition & 6 deletions ci-detector/src/main/java/io/github/tarek360/ci/Ci.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ package io.github.tarek360.ci
abstract class Ci {

open val gitHostToken: String? by lazy {
val token = Environment.getVariable("KOSHRY_GIT_HOST_TOKEN")
if (token.isNullOrBlank()) {
Environment.getVariable("DANGER_GITHUB_API_TOKEN")
} else {
token
}
Environment.getVariable("KOSHRY_GIT_HOST_TOKEN")
}

abstract val buildId: Int?
Expand Down
20 changes: 20 additions & 0 deletions ci-detector/src/main/java/io/github/tarek360/ci/TeamCityCi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.github.tarek360.ci

class TeamCityCi : Ci() {

override val buildId: Int? by lazy {
val buildId: String? = Environment.getVariable("TEAMCITY_BUILD_ID")
buildId?.toInt()
}

override val projectOwnerNameRepoName: String? by lazy {
Environment.getVariable("GITHUB_REPO_SLUG")
}

override val pullRequestId: Int? by lazy {
val teamcityBuildBranch =
Environment.getVariable("TEAMCITY_BUILD_BRANCH")?.split("/")
val id = teamcityBuildBranch?.get(0)
id?.toInt()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GitHub(private val gitHostInfo: GitHostInfo, isEnterprise: Boolean = false
// if it's not mocked web server
if (baseUrl.isEmpty()) {
baseUrl = if (isEnterprise) {
"https://${gitHostInfo.domain}/api/v3"
"https://${gitHostInfo.domain}/api/v3/"
} else {
"https://api.github.com/"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GitHubTest {
val gitHostInfo = GitHostInfo("github.enterprise-company.com", "tarek360/RichPath", 1, "abcd1234")
GitHub(gitHostInfo, true)

baseUrl mustEqual "https://github.enterprise-company.com/api/v3"
baseUrl mustEqual "https://github.enterprise-company.com/api/v3/"
}

@After
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
GROUP_ID=io.github.tarek360.koshry
VERSION=0.0.4
VERSION=0.0.4.3
BUILD_NUMBER=0
DESCRIPTION=Koshry for CI
BINTRAY_REPO=Koshry
19 changes: 9 additions & 10 deletions koshry/src/main/java/io/github/tarek360/koshry/CiProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package io.github.tarek360.koshry
import io.github.tarek360.ci.Ci
import io.github.tarek360.ci.CircleCi
import io.github.tarek360.ci.Environment
import io.github.tarek360.ci.TeamCityCi
import io.github.tarek360.ci.TravisCi

class CiProvider {

fun provide(): Ci? {
return when {
Environment.getVariable("TRAVIS") == "true" -> TravisCi()
Environment.getVariable("CIRCLECI") == "true" -> CircleCi()
else -> null
fun provide(): Ci? {
return when {
Environment.getVariable("TRAVIS") == "true" -> TravisCi()
Environment.getVariable("CIRCLECI") == "true" -> CircleCi()
Environment.getVariable("TEAMCITY_BUILD_ID")?.isNotBlank() == true -> TeamCityCi()
else -> null
}
}

}


}
}