-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add environment variables using configuration as code (#136)
* Add environment variables using configuration as code Signed-off-by: Sayali Gaikawad <[email protected]>
- Loading branch information
Showing
10 changed files
with
993 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { readFileSync } from 'fs'; | ||
|
||
/** | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
export class Env { | ||
public readonly key: string | ||
|
||
public readonly value: string | ||
|
||
constructor(key : string, value: string) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
} | ||
|
||
export class EnvConfig { | ||
public static addEnvConfigToJenkinsYaml(yamlObject: any, envVarsFilePath: string): any { | ||
const jenkinsYaml: any = yamlObject; | ||
const envArray: Env[] = []; | ||
const envFile: string = readFileSync(envVarsFilePath, 'utf-8'); | ||
const c = envFile.split('\n'); | ||
c.forEach((item) => { | ||
const e = item.split(':'); | ||
envArray.push(new Env(e[0], e[1])); | ||
}); | ||
|
||
const newEnvVars: Env[] = envArray; | ||
|
||
const envConfig: { [x: string]: any; } = { | ||
envVars: { | ||
env: newEnvVars, | ||
}, | ||
}; | ||
jenkinsYaml.jenkins.globalNodeProperties = [envConfig]; | ||
return jenkinsYaml; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.