Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let encodedStr = ini.encode(fileContent);
fs.writeFileSync(pypircPath, encodedStr);
}
else {
// create new
fs.writeFileSync(pypircPath, formPypircFormatFromData(newEndpointsToAdd));
tl.setVariable("PYPIRC_PATH", pypircPath, false);
tl.debug(tl.loc("VariableSetForPypirc", pypircPath));
}
// Configuring the pypirc file
console.log(tl.loc("Info_SuccessAddingAuth", internalFeeds.length, externalEndpoints.length));
}
catch (error) {
tl.error(error);
tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToAddAuthentication"));
return;
} finally{
_logTwineAuthStartupVariables();
}
}
// Telemetry
// Setting pip_index_url if onlyaddExtraIndex is false
let pipIndexEnvVar: string = "";
if (!onlyAddExtraIndex && internalAndExternalEndpoints.length > 0) {
pipIndexEnvVar = internalAndExternalEndpoints[0];
internalAndExternalEndpoints.shift();
tl.setVariable("PIP_INDEX_URL", pipIndexEnvVar, false);
}
// Setting pip_extra_index_url for rest of the endpoints
if (internalAndExternalEndpoints.length > 0) {
const extraIndexUrl = internalAndExternalEndpoints.join(" ");
tl.setVariable("PIP_EXTRA_INDEX_URL", extraIndexUrl, false);
const pipauthvar = tl.getVariable("PIP_EXTRA_INDEX_URL");
if (pipauthvar.length < extraIndexUrl.length){
tl.warning(tl.loc("Warn_TooManyFeedEntries"));
}
}
console.log(tl.loc("Info_SuccessAddingAuth", feedList.length, externalEndpoints.length));
}
catch (error) {
tl.error(error);
tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToAddAuthentication"));
return;
} finally{
_logPipAuthStartupVariables();
}
}
.substring(0, 255)
.toLowerCase();
const accessToken = pkgLocationUtils.getSystemAccessToken();
internalAuthInfo = new auth.InternalAuthInfo([], accessToken);
const feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);
packageName = await artifactToolUtilities.getPackageNameFromId(feedUri, accessToken, feedId, packageId);
// Getting package version from hash
version = `1.0.0-${hash}`;
toolRunnerOptions.env.UNIVERSAL_DOWNLOAD_PAT = internalAuthInfo.accessToken;
tl.debug(tl.loc("Info_UsingArtifactToolDownload"));
const downloadOptions = {
artifactToolPath,
feedId,
accountUrl: serviceUri,
packageName,
packageVersion: version,
} as artifactToolRunner.IArtifactToolOptions;
downloadPackageUsingArtifactTool(downloadDir, downloadOptions, toolRunnerOptions);
console.log('artifact downloaded');
return {
toolRan: true,
success: true,
};
entry.password);
fileContent["distutils"]["index-servers"] += " " + entry.packageSource.feedName;
}
let encodedStr = ini.encode(fileContent);
fs.writeFileSync(pypircPath, encodedStr);
}
else {
// create new
fs.writeFileSync(pypircPath, formPypircFormatFromData(newEndpointsToAdd));
tl.setVariable("PYPIRC_PATH", pypircPath, false);
tl.debug(tl.loc("VariableSetForPypirc", pypircPath));
}
// Configuring the pypirc file
console.log(tl.loc("Info_SuccessAddingAuth", internalFeeds.length, externalEndpoints.length));
}
catch (error) {
tl.error(error);
tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToAddAuthentication"));
return;
} finally{
_logTwineAuthStartupVariables();
}
}
// Telemetry
const feedList = tl.getDelimitedInput("artifactFeeds", ",");
const onlyAddExtraIndex = tl.getBoolInput("onlyAddExtraIndex");
// Local feeds
if (feedList)
{
tl.debug(tl.loc("Info_AddingInternalFeeds", feedList.length));
const serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
const localAccessToken = pkgLocationUtils.getSystemAccessToken();
try {
// This call is to get the packaging URI(abc.pkgs.vs.com) which is same for all protocols.
packagingLocation = await pkgLocationUtils.getNuGetUriFromBaseServiceUri(
serviceUri,
localAccessToken);
} catch (error) {
tl.debug(tl.loc("FailedToGetPackagingUri"));
tl.debug(JSON.stringify(error));
packagingLocation = serviceUri;
}
for (const feedName of feedList) {
const feed = getProjectAndFeedIdFromInput(feedName);
const feedUri = await pkgLocationUtils.getFeedRegistryUrl(
packagingLocation,
pkgLocationUtils.RegistryType.PyPiSimple,
feed.feedId,
feed.projectId,
localAccessToken);
const pipUri = utils.formPipCompatibleUri("build", localAccessToken, feedUri);
internalAndExternalEndpoints.push(pipUri);
}
}
function downloadPackageUsingArtifactTool(downloadDir: string, options: artifactToolRunner.IArtifactToolOptions, execOptions: IExecOptions) {
const command = new Array();
command.push("universal", "download",
"--feed", options.feedId,
"--service", options.accountUrl,
"--package-name", options.packageName,
"--package-version", options.packageVersion,
"--path", downloadDir,
"--patvar", "UNIVERSAL_DOWNLOAD_PAT",
"--verbosity", tl.getInput("verbosity"));
console.log(tl.loc("Info_Downloading", options.packageName, options.packageVersion, options.feedId));
const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(options.artifactToolPath, command, execOptions);
if (execResult.code === 0) {
return;
}
throw new Error(tl.loc("Error_UnexpectedErrorArtifactToolDownload",
execResult.code,
execResult.stderr ? execResult.stderr.trim() : execResult.stderr));
}
"--feed", options.feedId,
"--service", options.accountUrl,
"--package-name", options.packageName,
"--package-version", options.packageVersion,
"--path", publishDir,
"--patvar", "UNIVERSAL_PUBLISH_PAT",
"--verbosity", tl.getInput("verbosity"));
console.log(tl.loc("Info_Publishing", options.packageName, options.packageVersion, options.feedId));
const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(options.artifactToolPath, command, execOptions);
if (execResult.code === 0) {
return;
}
throw new Error(tl.loc("Error_UnexpectedErrorArtifactTool",
execResult.code,
execResult.stderr ? execResult.stderr.trim() : execResult.stderr));
}
let command = new Array();
command.push("universal", "download",
"--feed", options.feedId,
"--service", options.accountUrl,
"--package-name", options.packageName,
"--package-version", options.packageVersion,
"--path", downloadDir,
"--patvar", "UNIVERSAL_DOWNLOAD_PAT",
"--verbosity", tl.getInput("verbosity"));
if (options.projectId) {
command.push("--project", options.projectId);
}
console.log(tl.loc("Info_Downloading", options.packageName, options.packageVersion, options.feedId, options.projectId));
const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(options.artifactToolPath, command, execOptions);
if (execResult.code === 0) {
return;
}
telemetry.logResult("Packaging", "UniversalPackagesCommand", execResult.code);
throw new Error(tl.loc("Error_UnexpectedErrorArtifactToolDownload",
execResult.code,
execResult.stderr ? execResult.stderr.trim() : execResult.stderr));
}
apkVersionCode: apkVersionCode,
media: {
body: fs.createReadStream(mappingFilePath),
mimeType: ''
}
};
try {
tl.debug('Request Parameters: ' + JSON.stringify(requestParameters));
const res = (await edits.deobfuscationfiles.upload(requestParameters)).data;
tl.debug('returned: ' + JSON.stringify(res));
return res;
} catch (e) {
tl.debug(`Failed to upload deobfuscation file ${mappingFilePath}`);
tl.debug(e);
throw new Error(tl.loc('CannotUploadDeobfuscationFile', mappingFilePath, e));
}
}
throw new Error(tl.loc("Error_ProcessorArchitectureNotSupported"));
}
const blobstoreAreaName = "clienttools";
const blobstoreAreaId = "187ec90d-dd1e-4ec6-8c57-937d979261e5";
const ApiVersion = "5.0-preview";
const blobstoreConnection = pkgLocationUtils.getWebApiWithProxy(serviceUri, accessToken);
const artifactToolGetUrl = await blobstoreConnection.vsoClient.getVersioningData(ApiVersion, blobstoreAreaName, blobstoreAreaId, { toolName }, {osName, arch});
const artifactToolUri = await blobstoreConnection.rest.get(artifactToolGetUrl.requestUrl);
if (artifactToolUri.statusCode !== 200) {
tl.debug(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolUri.result.toString()));
throw new Error(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolGetUrl.requestUrl));
}
let artifactToolPath = toollib.findLocalTool(toolName, artifactToolUri.result['version']);
if (!artifactToolPath) {
tl.debug(tl.loc("Info_DownloadingArtifactTool", artifactToolUri.result['uri']));
const zippedToolsDir: string = await pkgLocationUtils.retryOnExceptionHelper(() => toollib.downloadTool(artifactToolUri.result['uri']), 3, 1000);
tl.debug("Downloaded zipped artifact tool to " + zippedToolsDir);
const unzippedToolsDir = await extractZip(zippedToolsDir);
artifactToolPath = await toollib.cacheDir(unzippedToolsDir, "ArtifactTool", artifactToolUri.result['version']);
} else {
tl.debug(tl.loc("Info_ResolvedToolFromCache", artifactToolPath));
}
return getArtifactToolLocation(artifactToolPath);