MCPcopy
hub / github.com/firecow/gitlab-ci-local / discourageOverridingOfPredefinedVariables

Method discourageOverridingOfPredefinedVariables

src/job.ts:292–310  ·  view source on GitHub ↗

* Warn when overriding of predefined variables is detected

(predefinedVariables: {[name: string]: string}, userDefinedVariables: {[name: string]: string}, whiteListedPredefinedVariablesKeys: string[])

Source from the content-addressed store, hash-verified

290 * Warn when overriding of predefined variables is detected
291 */
292 private discourageOverridingOfPredefinedVariables (predefinedVariables: {[name: string]: string}, userDefinedVariables: {[name: string]: string}, whiteListedPredefinedVariablesKeys: string[]) {
293 const predefinedVariablesKeys = Object.keys(predefinedVariables);
294 const userDefinedVariablesKeys = Object.keys(userDefinedVariables);
295
296 const overridingOfPredefinedVariables = userDefinedVariablesKeys.filter(ele => predefinedVariablesKeys.includes(ele) && !whiteListedPredefinedVariablesKeys.includes(ele));
297 if (overridingOfPredefinedVariables.length == 0) {
298 return;
299 }
300
301 const linkToGitlab = "https://gitlab.com/gitlab-org/gitlab/-/blob/v17.7.1-ee/doc/ci/variables/predefined_variables.md?plain=1&ref_type=tags#L15-16";
302 this.writeStreams.memoStdout(chalk`
303{bgYellowBright WARN } ${terminalLink("Avoid overriding predefined variables", linkToGitlab)} [{bold ${overridingOfPredefinedVariables}}] as it can cause the pipeline to behave unexpectedly.
304If you know what you're doing and would like to suppress this warning, use one of the following methods:
305\t• via cli options
306\t\t• --ignore-predefined-vars ${overridingOfPredefinedVariables}
307\t• via environment variable
308\t\t• GCL_IGNORE_PREDEFINED_VARS=${overridingOfPredefinedVariables}
309`);
310 }
311
312 /**
313 * Get the predefinedVariables that's enriched with the additional info that's only available when constructing

Callers 1

constructorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected