Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let serverId = buildName + "-" + buildNumber + "-forextractordownload";
try {
utils.configureCliServer(artifactoryService, serverId, cliPath, workDir);
} catch (ex) {
tl.setResult(tl.TaskResult.Failed, ex);
try {
utils.deleteCliServers(cliPath, workDir, [serverId]);
} catch (deleteServersException) {
tl.setResult(tl.TaskResult.Failed, deleteServersException);
}
return
}
// Set the environment variables needed for the cli to download the extractor from artifactory
// The extractor download will occur during the execution of the Artifactory Maven task, then the config and environment variables will be removed
tl.setVariable("JFROG_CLI_JCENTER_REMOTE_SERVER", serverId);
tl.setVariable("JFROG_CLI_JCENTER_REMOTE_REPO", tl.getInput("mavenInstallationRepo"));
tl.setResult(tl.TaskResult.Succeeded, "Tools installed successfully.")
}
return; // There is no custom module so do not need to validate
}
let credentials = deploymentJson.modulesContent.$edgeAgent["properties.desired"].runtime.settings.registryCredentials;
if (credentials) {
Object.keys(credentials).forEach((key: string) => {
let credential = credentials[key];
let loginResult = tl.execSync("docker", `login ${credential.address} -u ${credential.username} -p ${credential.password}`, Constants.execSyncSilentOption);
tl.debug(JSON.stringify(loginResult));
if (loginResult.code != 0) {
tl.warning(tl.loc("InvalidRegistryCredentialWarning", credential.address, loginResult.stderr));
}
});
}
tl.setVariable("DOCKER_CLI_EXPERIMENTAL", "enabled");
tl.debug(`Checking DOCKER_CLI_EXPERIMENTAL value: ${tl.getVariable("DOCKER_CLI_EXPERIMENTAL")}`);
let validationErr = "";
Object.keys(modules).forEach((key: string) => {
let module = modules[key];
let image = module.settings.image;
let manifestResult = tl.execSync("docker", `manifest inspect ${image}`, Constants.execSyncSilentOption);
tl.debug(JSON.stringify(manifestResult));
if (manifestResult.code != 0) {
validationErr += tl.loc("CheckModuleImageExistenceError", image, manifestResult.stderr) + "\n";
}
});
if (validationErr) {
throw new Error(validationErr);
}
}
catch (err) {
function setGoEnvironmentVariables(goRoot: string) {
tl.setVariable('GOROOT', goRoot);
const goPath: string = tl.getInput("goPath", false);
const goBin: string = tl.getInput("goBin", false);
// set GOPATH and GOBIN as user value
if (!util.isNullOrUndefined(goPath)) {
tl.setVariable("GOPATH", goPath);
}
if (!util.isNullOrUndefined(goBin)) {
tl.setVariable("GOBIN", goBin);
}
}
function setGoEnvironmentVariables(goRoot: string) {
tl.setVariable('GOROOT', goRoot);
let goPath: string = tl.getInput("goPath", false);
let goBin: string = tl.getInput("goBin", false);
// set GOPATH and GOBIN as user value
if (!util.isNullOrUndefined(goPath)) {
tl.setVariable("GOPATH", goPath);
}
if (!util.isNullOrUndefined(goBin)) {
tl.setVariable("GOBIN", goBin);
}
}
function setGoEnvironmentVariables(goRoot: string) {
tl.setVariable('GOROOT', goRoot);
const goPath: string = tl.getInput("goPath", false);
const goBin: string = tl.getInput("goBin", false);
// set GOPATH and GOBIN as user value
if (!util.isNullOrUndefined(goPath)) {
tl.setVariable("GOPATH", goPath);
}
if (!util.isNullOrUndefined(goBin)) {
tl.setVariable("GOBIN", goBin);
}
}
this.taskParameters.environmentName,
versionLabel,
this.taskParameters.description,
this.taskParameters.applicationType === applicationTypeExistingVersion
)
await this.waitForDeploymentCompletion(
this.taskParameters.applicationName,
this.taskParameters.environmentName,
startingEventDate,
this.taskParameters.eventPollingDelay
)
if (this.taskParameters.outputVariable) {
console.log(tl.loc('SettingOutputVariable', this.taskParameters.outputVariable, versionLabel))
tl.setVariable(this.taskParameters.outputVariable, versionLabel)
}
console.log(tl.loc('TaskCompleted', this.taskParameters.applicationName))
}
}
toolPath = toolLib.findLocalTool('tfx', version);
}
if (!toolPath) {
toolPath = await acquireTfx(version);
}
}
if (os.platform() !== "win32")
{
toolPath = path.join(toolPath, "/node_modules/.bin/");
}
taskLib.setVariable("__tfxpath", toolPath, false);
toolLib.prependPath(toolPath);
}
public close() {
if (tl.getVariable('KUBECONFIG')) {
tl.setVariable('KUBECONFIG', '');
}
}
}