Skip to content

Commit

Permalink
Add Bitrise CI support (#45)
Browse files Browse the repository at this point in the history
* Add Bitrise CI support

* Add docs for Bitrise
  • Loading branch information
wdziemia committed Mar 18, 2021
1 parent 195a8dc commit f6b1d90
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ The plugin can be used with the following CI providers:
* Codeship
* Buildkite
* Gitlab CI
* Bitrise


### Travis
Expand Down Expand Up @@ -363,3 +364,7 @@ See Buildkite environment variables [documentation](https://buildkite.com/docs/p
### Gitlab CI

See Gitlab CI predefined variables [documentation](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)

### Bitrise CI

See Bitrise CI predefined variables [documentation](https://devcenter.bitrise.io/builds/available-environment-variables/)
9 changes: 8 additions & 1 deletion src/main/kotlin/ServiceInfoParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ServiceInfoParser(val envGetter: EnvGetter) {
private val isGithubActionsToken = envGetter("GITHUB_TOKEN") != null
private val isBuildkite = envGetter("BUILDKITE") == "true"
private val isGitlab = envGetter("GITLAB_CI") != null
private val isBitrise = envGetter("BITRISE_IO") == "true"

fun parse(): ServiceInfo {
return when {
Expand Down Expand Up @@ -86,7 +87,13 @@ class ServiceInfoParser(val envGetter: EnvGetter) {
branch = envGetter("CI_COMMIT_BRANCH"),
buildUrl = envGetter("CI_PIPELINE_URL")
)

isBitrise -> ServiceInfo(
name = "bitrise",
number = envGetter("BITRISE_BUILD_NUMBER"),
pr = envGetter("BITRISE_PULL_REQUEST"),
branch = envGetter("BITRISE_GIT_BRANCH"),
buildUrl = envGetter("BITRISE_BUILD_URL")
)
else -> ServiceInfo("other")
}
}
Expand Down
24 changes: 22 additions & 2 deletions src/test/kotlin/ServiceInfoParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,34 @@ internal class ServiceInfoParserTest {
val envGetter = createEnvGetter(mapOf(
"GITLAB_CI" to "true",
"CI_PIPELINE_ID" to "12341234",
"CI_PIPELINE_URL" to "https://gitlab.com.com/your-group/your-repo/pipelines/123",
"CI_PIPELINE_URL" to "https://gitlab.com/your-group/your-repo/pipelines/123",
"CI_JOB_ID" to "43214321",
"CI_COMMIT_BRANCH" to "foobar",
"CI_MERGE_REQUEST_IID" to "11"
))

val actual = ServiceInfoParser(envGetter).parse()
val expected = ServiceInfo(name = "gitlab-ci", number = "12341234", jobId = "43214321", pr = "11", branch = "foobar", buildUrl = "https://gitlab.com.com/your-group/your-repo/pipelines/123")
val expected = ServiceInfo(name = "gitlab-ci", number = "12341234", jobId = "43214321", pr = "11", branch = "foobar", buildUrl = "https://gitlab.com/your-group/your-repo/pipelines/123")
assertEquals(expected, actual)
}

@Test
fun `ServiceInfoParser parses bitrise env`() {
val envGetter = createEnvGetter(mapOf(
"BITRISE_IO" to "true",
"BITRISE_BUILD_NUMBER" to "123123",
"BITRISE_PULL_REQUEST" to "11",
"BITRISE_GIT_BRANCH" to "foobar",
"BITRISE_BUILD_URL" to "https://app.bitrise.io/build/d75abbebxfc9ca4e"
))
val actual = ServiceInfoParser(envGetter).parse()
val expected = ServiceInfo(
name = "bitrise",
number = "123123",
pr = "11",
branch = "foobar",
buildUrl = "https://app.bitrise.io/build/d75abbebxfc9ca4e"
)
assertEquals(expected, actual)
}

Expand Down

0 comments on commit f6b1d90

Please sign in to comment.