Skip to content

Commit 3709aff

Browse files
committed
[RB] Support passing a different API key for uploading build events
1 parent 3197186 commit 3709aff

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/invocation/invocation_action_card.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ export default class InvocationActionCardComponent extends React.Component<Props
657657
) {
658658
const snapshotKey = this.getSnapshotKeyForSnapshotID(vmMetadata);
659659
const snapshotKeyJSON = JSON.stringify(snapshotKey);
660-
const cmd = `bb remote --run_from_snapshot='${snapshotKeyJSON}' --runner_exec_properties=debug-executor-id=${executionMetadata.executorId} --script='echo "My custom bash command!"'`;
660+
const impersonationAPIKey = this.state.user?.isImpersonating ? `--remote_run_header=x-buildbuddy-platform.env-overrides=BUILDBUDDY_BES_API_KEY=[SET BB ORG API KEY]>` : "";
661+
const cmd = `bb remote ${impersonationAPIKey} --run_from_snapshot='${snapshotKeyJSON}' --runner_exec_properties=debug-executor-id=${executionMetadata.executorId} --script='echo "My custom bash command!"'`;
661662
copyToClipboard(cmd);
662663
alert_service.success("Command copied to clipboard");
663664
this.setState({ showSnapshotMenu: false });

enterprise/server/cmd/ci_runner/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,13 @@ func run() error {
680680
defer cancel()
681681
}
682682

683+
besAPIKey := os.Getenv("BUILDBUDDY_BES_API_KEY")
684+
if besAPIKey == "" {
685+
besAPIKey = ws.buildbuddyAPIKey
686+
}
683687
// Use a context without a timeout for the build event reporter, so that even
684688
// if the `timeout` is reached, any events will finish getting published
685-
buildEventReporter, err := newBuildEventReporter(contextWithoutTimeout, *besBackend, ws.buildbuddyAPIKey, *invocationID, *workflowID != "" /*=isWorkflow*/)
689+
buildEventReporter, err := newBuildEventReporter(contextWithoutTimeout, *besBackend, besAPIKey, *invocationID, *workflowID != "" /*=isWorkflow*/)
686690
if err != nil {
687691
return err
688692
}

0 commit comments

Comments
 (0)