Skip to content

Commit 0e8b44a

Browse files
committed
fix(cli): skip profile loading in CI mode to use config file URLs
In CI environments (GitHub Actions, etc.), the CLI was incorrectly creating a default "cloud" profile that overrode the config file URLs. This caused E2E tests to fail when the local dev server was running but the CLI tried to push to the cloud API. Changes: - Skip profile loading entirely when CI is detected - Use config file URLs directly in CI mode without INKEEP_API_KEY - Log helpful message when CI mode uses config file settings - Still apply CI env var overrides when INKEEP_API_KEY is set This aligns with the CI/CD support design: detect CI, fall back to config file settings, support API key in inkeep.config.ts.
1 parent 2a8d5cb commit 0e8b44a

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

agents-cli/src/utils/cli-pipeline.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,42 +101,52 @@ export async function initializeCommand(
101101
const ciDetection = await detectCIEnvironment();
102102
const ciConfig = ciDetection.isCI ? loadCIEnvironmentConfig() : null;
103103

104-
// If in CI mode with API key, use CI configuration
105-
if (ciDetection.isCI && ciConfig) {
106-
// Load file config as base but override with CI env vars
104+
// In CI mode, use config file + CI env vars, skip profile loading entirely
105+
// This prevents ProfileManager from auto-creating a "cloud" profile that would
106+
// override config file URLs
107+
if (ciDetection.isCI) {
108+
// Load file config as base
107109
const config = await validateConfiguration(configPath, tag);
108110

109-
// CI env vars take precedence over file config
110-
if (ciConfig.manageApiUrl) {
111-
config.agentsManageApiUrl = ciConfig.manageApiUrl;
112-
}
113-
if (ciConfig.runApiUrl) {
114-
config.agentsRunApiUrl = ciConfig.runApiUrl;
115-
}
116-
if (ciConfig.apiKey) {
117-
config.agentsManageApiKey = ciConfig.apiKey;
118-
}
119-
if (ciConfig.tenantId) {
120-
config.tenantId = ciConfig.tenantId;
111+
// CI env vars take precedence over file config (if ciConfig is available)
112+
if (ciConfig) {
113+
if (ciConfig.manageApiUrl) {
114+
config.agentsManageApiUrl = ciConfig.manageApiUrl;
115+
}
116+
if (ciConfig.runApiUrl) {
117+
config.agentsRunApiUrl = ciConfig.runApiUrl;
118+
}
119+
if (ciConfig.apiKey) {
120+
config.agentsManageApiKey = ciConfig.apiKey;
121+
}
122+
if (ciConfig.tenantId) {
123+
config.tenantId = ciConfig.tenantId;
124+
}
121125
}
122126

123127
if (s) {
124128
s.stop('Configuration loaded');
125129
}
126130

127131
if (logConfig && !quiet) {
128-
logCIConfig(ciConfig, ciDetection.reason);
132+
if (ciConfig) {
133+
logCIConfig(ciConfig, ciDetection.reason);
134+
} else {
135+
console.log(chalk.yellow(`CI mode detected (${ciDetection.reason})`));
136+
console.log(chalk.gray(` Using config file settings (no INKEEP_API_KEY set)`));
137+
console.log(chalk.gray(` Remote: ${config.agentsManageApiUrl}`));
138+
}
129139
}
130140

131141
return {
132142
config,
133-
isAuthenticated: !!ciConfig.apiKey,
143+
isAuthenticated: !!ciConfig?.apiKey,
134144
isCI: true,
135-
ciConfig,
145+
ciConfig: ciConfig ?? undefined,
136146
};
137147
}
138148

139-
// Try to load profile configuration
149+
// Non-CI mode: Try to load profile configuration
140150
let profile: ResolvedProfile | undefined;
141151
let isAuthenticated = false;
142152
let authExpiry: string | undefined;

0 commit comments

Comments
 (0)