Skip to content

Commit

Permalink
Merge pull request #83 from gardleopard/travis_repository_sync_v2
Browse files Browse the repository at this point in the history
Sync repositories in travis for the spinnaker github user
  • Loading branch information
tomaslin committed Apr 27, 2016
2 parents bd985fc + 6f69c1e commit 4d34d79
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion igor-web/config/igor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ netflix:
spinnaker:
build:
pollInterval: 30

endpoints.health.sensitive: false

#travis:
# enabled: true
# Repository sync makes a call to travis telling travis to sync repos against github.
# This makes new repos with builds in travis the github user has access to tracked by spinnaker.
# repositorySyncEnabled: true
# Travis names are prefixed with travis- inside igor.
# masters:
# - name: ci # This will show as travis-ci inside spinnaker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class TravisBuildMonitor implements PollingMonitor{
@Value('${spinnaker.build.pollInterval:60}')
int pollInterval

@SuppressWarnings('GStringExpressionWithinString')
@Value('${travis.repositorySyncEnabled:false}')
Boolean repositorySyncEnabled

@Override
void onApplicationEvent(ContextRefreshedEvent event) {
log.info('Started')
Expand Down Expand Up @@ -217,8 +221,12 @@ class TravisBuildMonitor implements PollingMonitor{
}, {
} as Action0
)

log.info("Last poll took ${System.currentTimeMillis() - lastPoll}ms (master: ${master})")
if (repositorySyncEnabled) {
startTime = System.currentTimeMillis()
travisService.syncRepos()
log.info("repositorySync: Took ${System.currentTimeMillis() - startTime}ms to sync repositories for ${master}")
}
results

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ interface TravisClient {
@Headers("Travis-API-Version: 3")
TriggerResponse triggerBuild(@Header("Authorization") String accessToken, @Path('repoSlug') String repoSlug, @Body RepoRequest repoRequest)

@POST('/users/sync')
Response usersSync(@Header("Authorization") String accessToken)

@GET('/jobs/{job_id}')
Jobs jobs(@Header("Authorization") String accessToken , @Path('job_id') int jobId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ class TravisService implements BuildService {
return true
}

void syncRepos() {
try {
travisClient.usersSync(getAccessToken())
} catch (RetrofitError e) {
log.error "synchronizing travis repositories failed with error: ${e.message}"
}
}

@Override
BuildServiceProvider buildServiceProvider() {
return BuildServiceProvider.TRAVIS
Expand Down

0 comments on commit 4d34d79

Please sign in to comment.