Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function useCpythonVersion(parameters: Readonly, platform: Platform): Promise {
const desugaredversion = desugarDevVersion(parameters.version);
const semanticversion: string = pythonVersionToSemantic(desugaredversion);
task.debug(`Semantic version spec of ${parameters.version} is ${semanticversion}`);
const installDir: string | null = tool.findLocalTool('Python', semanticversion, parameters.architecture);
console.log('INSTALL DIR - ' + installDir);
if (!installDir) {
// Fail and list available versions
const x86Versions = tool.findLocalToolVersions('Python', 'x86')
.map(s => `${s} (x86)`)
.join(os.EOL);
const x64Versions = tool.findLocalToolVersions('Python', 'x64')
.map(s => `${s} (x64)`)
.join(os.EOL);
throw new Error([
task.loc('VersionNotFound', parameters.version, parameters.architecture),
task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
console.log('yuniql/input_additionalArguments: ' + additionalArguments);
console.log('yuniql/var_osPlat: ' + osPlat);
console.log('yuniql/var_osArch: ' + osArch);
//picksup the version downloaded from install task
let versionLocation: string = '';
if (toolLib.isExplicitVersion(versionSpec)) {
versionLocation = versionSpec;
} else {
//use v0.0.0 as placeholder for latest version
versionLocation = 'v0.0.0'
}
if (osPlat == 'win32') {
var yuniqlBasePath = path.join(toolLib.findLocalTool('yuniql', versionLocation));
console.log('yuniql/var_yuniqlBasePath: ' + yuniqlBasePath);
var yuniqlExecFilePath = path.join(yuniqlBasePath, 'yuniql.exe');
console.log('yuniql/var_yuniqlExecFilePath: ' + yuniqlExecFilePath);
//set the plugin path
// var pluginsPath = path.join(yuniqlBasePath, '.plugins');
// console.log('var_pluginsPath: ' + pluginsPath);
//builds up the arguments structure
let yuniql = new tr.ToolRunner(yuniqlExecFilePath);
yuniql.arg('run');
// yuniql.arg('--plugins-path');
// yuniql.arg(pluginsPath);
async function getTfx(versionSpec: string, checkLatest: boolean) {
if (toolLib.isExplicitVersion(versionSpec)) {
checkLatest = false; // check latest doesn't make sense when explicit version
}
let toolPath: string;
if (!checkLatest) {
toolPath = toolLib.findLocalTool('tfx', versionSpec);
}
if (!toolPath) {
let version: string;
if (toolLib.isExplicitVersion(versionSpec)) {
version = versionSpec;
}
else {
version = queryLatestMatch(versionSpec);
if (!version) {
throw new Error(`Unable to find Tfx version '${versionSpec}'`);
}
toolPath = toolLib.findLocalTool('tfx', version);
}
async function getGo(version: string) {
// check cache
let toolPath: string;
toolPath = toolLib.findLocalTool('go', fixVersion(version));
if (!toolPath) {
// download, extract, cache
toolPath = await acquireGo(version);
tl.debug("Go tool is cached under " + toolPath);
}
setGoEnvironmentVariables(toolPath);
toolPath = path.join(toolPath, 'bin');
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
toolLib.prependPath(toolPath);
}
const ApiVersion = "5.0-preview";
const blobstoreConnection = pkgLocationUtils.getWebApiWithProxy(serviceUri, accessToken);
try {
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.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 toollib.downloadTool(artifactToolUri.result['uri']);
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);
} catch (err) {
tl.warning(err);
// TODO: Should return null?
export async function downloadDocker(version: string, releaseType: string): Promise {
//docker does not follow strict semversion and has leading zeros in versions <10
var cleanVersion = version.replace(/(0+)([1-9]+)/,"$2");
var cachedToolpath = toolLib.findLocalTool(dockerToolName + "-" + releaseType, cleanVersion);
if (!cachedToolpath) {
try {
var dockerDownloadPath = await toolLib.downloadTool(getDockerDownloadURL(version, releaseType), dockerToolName + "-" + uuidV4() + getArchiveExtension());
} catch (exception) {
throw new Error(tl.loc("DockerDownloadFailed", getDockerDownloadURL(version, releaseType), exception));
}
var unzipedDockerPath;
if(isWindows) {
unzipedDockerPath = await toolLib.extractZip(dockerDownloadPath);
} else {
//tgz is a tar file packaged using gzip utility
unzipedDockerPath = await toolLib.extractTar(dockerDownloadPath);
}
function addToPathAndExec(cliPath, nugetCommand, nugetVersion) {
let toolPath = toolLib.findLocalTool(NUGET_TOOL_NAME, nugetVersion);
toolLib.prependPath(toolPath);
exec(cliPath, nugetCommand);
}
if (!checkLatest) {
toolPath = toolLib.findLocalTool('tfx', versionSpec);
}
if (!toolPath) {
let version: string;
if (toolLib.isExplicitVersion(versionSpec)) {
version = versionSpec;
}
else {
version = queryLatestMatch(versionSpec);
if (!version) {
throw new Error(`Unable to find Tfx version '${versionSpec}'`);
}
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);
}