in node/internal.ts [696:765]
export function _loadData(): void {
// in agent, prefer TempDirectory then workFolder.
// In interactive dev mode, it won't be
let keyPath: string = _getVariable("agent.TempDirectory") || _getVariable("agent.workFolder") || process.cwd();
_vault = new vm.Vault(keyPath);
_knownVariableMap = {};
_debug('loading inputs and endpoints');
let loaded: number = 0;
for (let envvar in process.env) {
if (_startsWith(envvar, 'INPUT_') ||
_startsWith(envvar, 'ENDPOINT_AUTH_') ||
_startsWith(envvar, 'SECUREFILE_TICKET_') ||
_startsWith(envvar, 'SECRET_') ||
_startsWith(envvar, 'VSTS_TASKVARIABLE_')) {
// Record the secret variable metadata. This is required by getVariable to know whether
// to retrieve the value from the vault. In a 2.104.1 agent or higher, this metadata will
// be overwritten when the VSTS_SECRET_VARIABLES env var is processed below.
if (_startsWith(envvar, 'SECRET_')) {
let variableName: string = envvar.substring('SECRET_'.length);
if (variableName) {
// This is technically not the variable name (has underscores instead of dots),
// but it's good enough to make getVariable work in a pre-2.104.1 agent where
// the VSTS_SECRET_VARIABLES env var is not defined.
_knownVariableMap[_getVariableKey(variableName)] = <_KnownVariableInfo>{ name: variableName, secret: true };
}
}
// store the secret
var value = process.env[envvar];
if (value) {
++loaded;
_debug('loading ' + envvar);
_vault.storeSecret(envvar, value);
delete process.env[envvar];
}
}
}
_debug('loaded ' + loaded);
// store public variable metadata
let names: string[];
try {
names = JSON.parse(process.env['VSTS_PUBLIC_VARIABLES'] || '[]');
}
catch (err) {
throw new Error('Failed to parse VSTS_PUBLIC_VARIABLES as JSON. ' + err); // may occur during interactive testing
}
names.forEach((name: string) => {
_knownVariableMap[_getVariableKey(name)] = <_KnownVariableInfo>{ name: name, secret: false };
});
delete process.env['VSTS_PUBLIC_VARIABLES'];
// store secret variable metadata
try {
names = JSON.parse(process.env['VSTS_SECRET_VARIABLES'] || '[]');
}
catch (err) {
throw new Error('Failed to parse VSTS_SECRET_VARIABLES as JSON. ' + err); // may occur during interactive testing
}
names.forEach((name: string) => {
_knownVariableMap[_getVariableKey(name)] = <_KnownVariableInfo>{ name: name, secret: true };
});
delete process.env['VSTS_SECRET_VARIABLES'];
// avoid loading twice (overwrites .taskkey)
global['_vsts_task_lib_loaded'] = true;
}