Skip to content

Commit

Permalink
Pick up branch name from travis environment variable (#102)
Browse files Browse the repository at this point in the history
* Pick up branch name from travis environment variable

* Add possible missing branch definition
  • Loading branch information
andreldm authored Feb 16, 2020
1 parent c3c856b commit 1463aa3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class ServiceInfoFactory {
return new ServiceInfo(
serviceName: env.get('CI_NAME') ?: 'travis-pro',
serviceJobId: env.get('TRAVIS_JOB_ID'),
serviceBranch: env.get('TRAVIS_BRANCH'),
repoToken: env.get('COVERALLS_REPO_TOKEN'),
environment: [
'travis_job_id' : env.get('TRAVIS_JOB_ID'),
'travis_pull_request': env.get('TRAVIS_PULL_REQUEST')]
'travis_pull_request': env.get('TRAVIS_PULL_REQUEST'),
'branch' : env.get('TRAVIS_BRANCH')]
)
} else if (envIsCircleci(env)) {
String prId = env.get('CI_PULL_REQUEST')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ class ServiceInfoFactoryTest {
TRAVIS: 'true',
TRAVIS_JOB_ID: '12345678',
COVERALLS_REPO_TOKEN: 'ABCDEF',
TRAVIS_PULL_REQUEST: '3232')
TRAVIS_PULL_REQUEST: '3232',
TRAVIS_BRANCH: 'branchX')

assertEquals 'travis-ci', serviceInfo.serviceName
assertEquals '12345678', serviceInfo.serviceJobId
assertEquals 'ABCDEF', serviceInfo.repoToken

assertEquals '12345678', serviceInfo.environment['travis_job_id']
assertEquals '3232', serviceInfo.environment['travis_pull_request']
assertEquals 'branchX', serviceInfo.environment['branch']
}

@Test
Expand All @@ -54,14 +56,16 @@ class ServiceInfoFactoryTest {
TRAVIS: 'true',
TRAVIS_JOB_ID: '12345678',
COVERALLS_REPO_TOKEN: 'ABCDEF',
TRAVIS_PULL_REQUEST: '3232')
TRAVIS_PULL_REQUEST: '3232',
TRAVIS_BRANCH: 'branchX')

assertEquals 'travis-pro', serviceInfo.serviceName
assertEquals '12345678', serviceInfo.serviceJobId
assertEquals 'ABCDEF', serviceInfo.repoToken

assertEquals '12345678', serviceInfo.environment['travis_job_id']
assertEquals '3232', serviceInfo.environment['travis_pull_request']
assertEquals 'branchX', serviceInfo.environment['branch']
}


Expand Down

0 comments on commit 1463aa3

Please sign in to comment.