Skip to content

Commit

Permalink
feat: Cloud Build integration for CI Reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
vlasy committed May 6, 2021
1 parent 3009255 commit 15d9bd0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/reporters/CIReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ScanningStrategyDetectorUtils } from '../detectors/utils/ScanningStrate
import { assertNever } from '../lib/assertNever';
import { ArgumentsProvider } from '../scanner';
import { RepositoryConfig } from '../scanner/RepositoryConfig';
import { BitbucketService, GitHubService, IVCSService, VCSServiceType } from '../services';
import { BitbucketService, GitHubService, IVCSService, VCSServiceType, GitServiceUtils } from '../services';
import { CreatedUpdatedPullRequestComment, PullRequestComment } from '../services/git/model';
import { GitLabClient } from '../services/gitlab/gitlabClient/gitlabUtils';
import { GitLabService } from '../services/gitlab/GitLabService';
Expand Down Expand Up @@ -182,6 +182,21 @@ export class CIReporter implements IReporter {
name: ev.CI_PROJECT_NAME!,
},
};
} else if (ev.CLOUDBUILD_PR_NUMBER && ev.CLOUDBUILD_HEAD_REPO_URL) {
if (!ScanningStrategyDetectorUtils.isGitHubPath(ev.CLOUDBUILD_HEAD_REPO_URL)) {
this.d('Cloud Build integration works only for Github repositories');
return undefined;
}
const repositoryInfo = GitServiceUtils.parseUrl(ev.CLOUDBUILD_HEAD_REPO_URL);
this.d('Is Google Cloud Buld');
return {
service: VCSServiceType.github,
pullRequestId: Number(ev.CLOUDBUILD_PR_NUMBER),
repository: {
owner: repositoryInfo.owner,
name: repositoryInfo.repoName,
},
};
} else {
// not supported yet
this.d('Is undefined CI');
Expand Down

0 comments on commit 15d9bd0

Please sign in to comment.