Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let nugetExec = tl.which("nuget", false);
if (!nugetExec && nugetCommand.localeCompare("restore") === 0) {
let localVersions = toolLib.findLocalToolVersions(NUGET_TOOL_NAME);
if (localVersions === undefined || localVersions.length === 0) {
await(downloadAndRunNuget(cliPath, nugetCommand));
} else {
console.log("The following version/s " + localVersions + " were found on the build agent");
addToPathAndExec(cliPath, nugetCommand, localVersions[localVersions.length - 1]);
}
} else {
exec(cliPath, nugetCommand);
}
});
if (process.platform !== "win32") {
tl.setResult(tl.TaskResult.Failed, "This task currently supports Windows agents only.");
return;
}
utils.executeCliTask(RunTaskCbk);
// Executing JFrog CLI with NuGet
function exec(cliPath, nugetCommand) {
let buildDir = tl.getVariable('System.DefaultWorkingDirectory');
// Get configured parameters
let nugetCommandCli;
if (nugetCommand.localeCompare("restore") === 0) {
// Perform restore command.
let solutionPattern = tl.getInput("solutionPath");
let filesList = solutionPathUtil.resolveFilterSpec(solutionPattern, tl.getVariable("System.DefaultWorkingDirectory") || process.cwd());
filesList.forEach(solutionFile => {
let solutionPath;
let cliCommand = utils.cliJoin(cliPath, cliUploadCommand, "--url=" + utils.quote(artifactoryUrl), "--spec=" + utils.quote(specPath));
cliCommand = utils.addArtifactoryCredentials(cliCommand, artifactoryService);
cliCommand = utils.addBoolParam(cliCommand, "failNoOp", "fail-no-op");
// Add build info collection
if (collectBuildInfo) {
let buildName = tl.getInput('buildName', true);
let buildNumber = tl.getInput('buildNumber', true);
cliCommand = utils.cliJoin(cliCommand, "--build-name=" + utils.quote(buildName), "--build-number=" + utils.quote(buildNumber));
}
try {
utils.executeCliCommand(cliCommand, workDir);
} catch (executionException) {
tl.setResult(tl.TaskResult.Failed, executionException);
} finally {
// Remove created fileSpec from file system.
try {
tl.rmRF(specPath);
} catch (fileException) {
tl.setResult(tl.TaskResult.Failed, "Failed cleaning temporary FileSpec file.");
}
}
// Ignored if previously failed.
tl.setResult(tl.TaskResult.Succeeded, "Build Succeeded.");
}
function performGenericDownload(cliPath, workDir, artifactoryService, artifactoryUrl) {
let specPath = path.join(workDir, "downloadSpec" + Date.now() + ".json");
// Get input parameters.
let specSource = tl.getInput("specSource", false);
let collectBuildInfo = tl.getBoolInput("collectBuildInfo");
// Create download FileSpec.
try {
utils.writeSpecContentToSpecPath(specSource, specPath);
} catch (ex) {
tl.setResult(tl.TaskResult.Failed, ex);
return;
}
// Build the cli command.
let cliCommand = utils.cliJoin(cliPath, cliDownloadCommand, "--url=" + utils.quote(artifactoryUrl), "--spec=" + utils.quote(specPath));
cliCommand = utils.addArtifactoryCredentials(cliCommand, artifactoryService);
cliCommand = utils.addBoolParam(cliCommand, "failNoOp", "fail-no-op");
// Add build info collection.
if (collectBuildInfo) {
let buildName = tl.getInput('buildName', true);
let buildNumber = tl.getInput('buildNumber', true);
cliCommand = utils.cliJoin(cliCommand, "--build-name=" + utils.quote(buildName), "--build-number=" + utils.quote(buildNumber));
}
// Execute the cli command.
try {
task.setResourcePath(path.join(__dirname, 'task.json'));
await usePythonVersion({
version: task.getInput('version', false),
architecture: task.getInput('architecture', true)
},
getPlatform());
// Always set proxy.
const proxy: tl.ProxyConfiguration | null = tl.getHttpProxyConfiguration();
if (proxy) {
proxyutil.setProxy(proxy);
}
task.setResult(task.TaskResult.Succeeded, "");
} catch (error) {
task.setResult(task.TaskResult.Failed, error.message);
}
})();
const inProgressTrack = track.releases.find(x => x.status === 'inProgress');
if (!inProgressTrack) {
throw new Error(tl.loc('InProgressNotFound'));
}
console.log(tl.loc('CurrentUserFrac', inProgressTrack.userFraction));
const updatedTrack: googleutil.Track = await googleutil.updateTrack(edits, packageName, rolloutTrack, inProgressTrack.versionCodes, userFraction, inProgressTrack.releaseNotes);
tl.debug('Update Track: ' + JSON.stringify(updatedTrack));
console.log(tl.loc('RolloutFracUpdate'));
const commit = await edits.commit();
tl.debug('Commit: ' + JSON.stringify(commit.data));
tl.setResult(tl.TaskResult.Succeeded, tl.loc('Success'));
} catch (err) {
tl.setResult(tl.TaskResult.Failed, err);
}
}
if (overrideNpmrc) {
tl.rmRF(projectNpmrc());
}
restoreProjectNpmrc(overrideNpmrc);
tl.rmRF(npmrc);
if (result) {
tl.setResult(
tl.TaskResult.Failed,
`Yarn failed with exit code ${result}`
);
} else {
tl.setResult(tl.TaskResult.Succeeded, "Yarn executed successfully");
}
} catch (err) {
tl.debug(String(err));
if (err.stack) {
tl.debug(err.stack);
}
tl.setResult(tl.TaskResult.Failed, String(err));
} finally {
tl.rmRF(util.getTempPath());
}
}
function setTaskResult(taskSuccessful) {
if (taskSuccessful) {
tl.setResult(tl.TaskResult.Succeeded, "Conan Task finished.");
} else {
tl.setResult(tl.TaskResult.Failed, "Conan Task failed.");
}
}
.catch((error) => tl.setResult(tl.TaskResult.Failed, !!error.message ? error.message : error));
}, (ex) => {
tl.setResult(tl.TaskResult.Failed, "ShouldNotHaveThrown");
});
}, (ex) => {
main().catch(error => {
tl.rmRF(util.getTempPath());
tl.setResult(tl.TaskResult.Failed, error);
});