Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tl.debug("Working directories do not match: ");
tl.debug("cwd: " + process.cwd());
tl.debug("expected cwd: " + cwd);
tl.debug("task will likely fail");
}
// If function arguments are provided (e.g. during test), use those, else, get user inputs provided by VSTS.
var authType = tl.getInput("authType", false);
if (authType === "AccessKey") {
accessKey = tl.getInput("accessKey", true);
} else if (authType === "ServiceEndpointCodePush" || authType === "ServiceEndpointHockeyApp") {
var serviceAccount = tl.getEndpointAuthorization(tl.getInput(authType, true));
accessKey = serviceAccount.parameters.password;
}
appName = appName || tl.getInput("appName", true);
deploymentName = deploymentName || tl.getInput("deploymentName", false);
platform = platform || tl.getInput("platform", true);
shouldBuild = shouldBuild || tl.getBoolInput("shouldBuild", false);
appStoreVersion = appStoreVersion || tl.getInput("appStoreVersion", false);
rollout = rollout || tl.getInput("rollout", false);
description = description || tl.getInput("description", false);
isMandatory = isMandatory || tl.getBoolInput("isMandatory", false);
isDisabled = isDisabled || tl.getBoolInput("isDisabled", false);
if (!accessKey) {
console.error("Access key required");
tl.setResult(1, "Access key required");
}
// Ensure all other users are logged out.
// If function arguments are provided (e.g. during test), use those, else, get user inputs provided by VSTS.
var authType = tl.getInput("authType", false);
if (authType === "AccessKey") {
accessKey = tl.getInput("accessKey", true);
} else if (authType === "ServiceEndpointCodePush" || authType === "ServiceEndpointHockeyApp") {
var serviceAccount = tl.getEndpointAuthorization(tl.getInput(authType, true));
accessKey = serviceAccount.parameters.password;
}
appName = appName || tl.getInput("appName", true);
deploymentName = deploymentName || tl.getInput("deploymentName", true);
label = label || tl.getInput("releaseLabel", false);
description = description || tl.getInput("description", false);
isDisabled = isDisabled || tl.getInput("isDisabled", false);
isMandatory = isMandatory || tl.getInput("isMandatory", false);
rollout = rollout || tl.getInput("rollout", false);
appStoreVersion = appStoreVersion || tl.getInput("appStoreVersion", true);
if (!accessKey) {
console.error("Access key required");
tl.setResult(1, "Access key required");
}
var codePushSdk = new CodePushSdk(accessKey);
codePushSdk.patchRelease(
appName, deploymentName, (label === "latest" ? null : label),
{
description: (description === "noChange" ? null : description),
disabled: (isDisabled === "noChange" ? null : isDisabled),
mandatory: (isMandatory === "noChange" ? null : isMandatory),
rollout: (rollout === "noChange" ? null : parseInt(rollout.replace("%", ""))),
targetBinaryVersion: (appStoreVersion === "noChange" ? null : appStoreVersion)
function performPatchTask(accessKey, appName, deploymentName, label, description, isDisabled, isMandatory, rollout, appStoreVersion) {
// If function arguments are provided (e.g. during test), use those, else, get user inputs provided by VSTS.
var authType = tl.getInput("authType", false);
if (authType === "AccessKey") {
accessKey = tl.getInput("accessKey", true);
} else if (authType === "ServiceEndpointCodePush" || authType === "ServiceEndpointHockeyApp") {
var serviceAccount = tl.getEndpointAuthorization(tl.getInput(authType, true));
accessKey = serviceAccount.parameters.password;
}
appName = appName || tl.getInput("appName", true);
deploymentName = deploymentName || tl.getInput("deploymentName", true);
label = label || tl.getInput("releaseLabel", false);
description = description || tl.getInput("description", false);
isDisabled = isDisabled || tl.getInput("isDisabled", false);
isMandatory = isMandatory || tl.getInput("isMandatory", false);
rollout = rollout || tl.getInput("rollout", false);
appStoreVersion = appStoreVersion || tl.getInput("appStoreVersion", true);
if (!accessKey) {
console.error("Access key required");
tl.setResult(1, "Access key required");
}
var codePushSdk = new CodePushSdk(accessKey);
codePushSdk.patchRelease(
appName, deploymentName, (label === "latest" ? null : label),
{
function performPromoteTask(accessKey, appName, sourceDeploymentName, targetDeploymentName, appStoreVersion, description, rollout, isMandatory, isDisabled) {
// If function arguments are provided (e.g. during test), use those, else, get user inputs provided by VSTS.
var authType = tl.getInput("authType", false);
if (authType === "AccessKey") {
accessKey = tl.getInput("accessKey", true);
} else if (authType === "ServiceEndpointCodePush" || authType === "ServiceEndpointHockeyApp") {
var serviceAccount = tl.getEndpointAuthorization(tl.getInput(authType, true));
accessKey = serviceAccount.parameters.password;
}
appName = appName || tl.getInput("appName", true);
sourceDeploymentName = sourceDeploymentName || tl.getInput("sourceDeploymentName", true);
targetDeploymentName = targetDeploymentName || tl.getInput("targetDeploymentName", true);
appStoreVersion = appStoreVersion || tl.getInput("appStoreVersion", false);
description = description || tl.getInput("description", false);
rollout = rollout || tl.getInput("rollout", false);
isMandatory = isMandatory || tl.getInput("isMandatory", true);
isDisabled = isDisabled || tl.getInput("isDisabled", true);
if (!accessKey) {
console.error("Access key required");
tl.setResult(1, "Access key required");
}
var updateMetadata = {
targetBinaryVersion: appStoreVersion === "Inherit" ? null : appStoreVersion,
description: description === "Inherit" ? null : description,
tl.debug("cwd: " + process.cwd());
tl.debug("expected cwd: " + cwd);
tl.debug("task will likely fail");
}
// If function arguments are provided (e.g. during test), use those, else, get user inputs provided by VSTS.
var authType = tl.getInput("authType", false);
if (authType === "AccessKey") {
accessKey = tl.getInput("accessKey", true);
} else if (authType === "ServiceEndpointCodePush" || authType === "ServiceEndpointHockeyApp") {
var serviceAccount = tl.getEndpointAuthorization(tl.getInput(authType, true));
accessKey = serviceAccount.parameters.password;
}
appName = appName || tl.getInput("appName", true);
deploymentName = deploymentName || tl.getInput("deploymentName", false);
platform = platform || tl.getInput("platform", true);
shouldBuild = shouldBuild || tl.getBoolInput("shouldBuild", false);
appStoreVersion = appStoreVersion || tl.getInput("appStoreVersion", false);
rollout = rollout || tl.getInput("rollout", false);
description = description || tl.getInput("description", false);
isMandatory = isMandatory || tl.getBoolInput("isMandatory", false);
isDisabled = isDisabled || tl.getBoolInput("isDisabled", false);
if (!accessKey) {
console.error("Access key required");
tl.setResult(1, "Access key required");
}
// Ensure all other users are logged out.
try {
// If function arguments are provided (e.g. during test), use those, else, get user inputs provided by VSTS.
var authType = tl.getInput("authType", false);
if (authType === "AccessKey") {
accessKey = tl.getInput("accessKey", true);
} else if (authType === "ServiceEndpointCodePush" || authType === "ServiceEndpointHockeyApp") {
var serviceAccount = tl.getEndpointAuthorization(tl.getInput(authType, true));
accessKey = serviceAccount.parameters.password;
}
appName = appName || tl.getInput("appName", true);
deploymentName = deploymentName || tl.getInput("deploymentName", false);
platform = platform || tl.getInput("platform", true);
shouldBuild = shouldBuild || tl.getBoolInput("shouldBuild", false);
appStoreVersion = appStoreVersion || tl.getInput("appStoreVersion", false);
rollout = rollout || tl.getInput("rollout", false);
description = description || tl.getInput("description", false);
isMandatory = isMandatory || tl.getBoolInput("isMandatory", false);
isDisabled = isDisabled || tl.getBoolInput("isDisabled", false);
if (!accessKey) {
console.error("Access key required");
tl.setResult(1, "Access key required");
}
// Ensure all other users are logged out.
try {
ensureLoggedOut();
} catch (e) {
// not logged in
}
let _this = this;
// get the task vars
let connection = tl.getInput("connection", true);
let endpointUrl = tl.getEndpointUrl(connection, false);
let auth = tl.getEndpointAuthorization(connection, false);
if (auth.scheme !== "Token") {
throw new Error(`The authorization scheme ${auth.scheme} is not supported for GitLab endpoint`);
}
let token = auth.parameters["apitoken"];
let username = tl.getEndpointDataParameter(connection, "username", false);
let definition = tl.getInput("definition", true);
let branch = tl.getInput("branch");
let downloadPath = tl.getInput("downloadPath", false);
let versionSelector = tl.getInput("versionSelector", true);
let commitId = tl.getInput("version");
let debugOutput = tl.getVariable("system.debug");
debugOutput = debugOutput || "false";
let isDebugOutput: boolean = debugOutput.toLowerCase() === "true";
// print what is supplied by the user
tl.debug(`endpoint: ${JSON.stringify(auth)}`);
tl.debug(`definition: ${definition}`);
tl.debug(`branch: ${branch}`);
tl.debug(`downloadPath: ${downloadPath}`);
tl.debug(`versionSelector: ${versionSelector}`);
tl.debug(`commitId: ${commitId}`);
tl.debug(`debugOutput: ${debugOutput}`);
if (!downloadPath || downloadPath.length === 0) {
downloadPath = tl.getVariable("System.DefaultWorkingDirectory");
}
return __awaiter(this, void 0, void 0, function* () {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
const failOnStderr = tl.getBoolInput('failOnStderr', false);
const workingDirectory = tl.getInput('workingDirectory', false);
const additionalParameters = tl.getInput('additionalParameters', false);
if (workingDirectory != '') {
shell.cd(workingDirectory);
}
let fileName = 'runsbttests.sh';
let filePath = path.join(__dirname, fileName);
let runSbtExec = shell.exec(`bash ${filePath} ${additionalParameters}`.trim());
if (runSbtExec.code != 0) {
tl.setResult(tl.TaskResult.Failed, `Error while executing command: ${runSbtExec.stderr}`);
}
if (failOnStderr && runSbtExec.stderr != "") {
tl.setResult(tl.TaskResult.Failed, `Command wrote to stderr: ${runSbtExec.stderr}`);
}
}
catch (err) {
tl.setResult(tl.TaskResult.Failed, err.message);
return __awaiter(this, void 0, void 0, function* () {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
const failOnStderr = tl.getBoolInput('failOnStderr', false);
const workingDirectory = tl.getInput('workingDirectory', false);
const additionalParameters = tl.getInput('additionalParameters', false);
if (workingDirectory != '') {
shell.cd(workingDirectory);
}
let fileName = 'runsbttests.sh';
let filePath = path.join(__dirname, fileName);
let runSbtExec = shell.exec(`bash ${filePath} ${additionalParameters}`.trim());
if (runSbtExec.code != 0) {
tl.setResult(tl.TaskResult.Failed, `Error while executing command: ${runSbtExec.stderr}`);
}
if (failOnStderr && runSbtExec.stderr != "") {
tl.setResult(tl.TaskResult.Failed, `Command wrote to stderr: ${runSbtExec.stderr}`);
}
}
catch (err) {
tl.setResult(tl.TaskResult.Failed, err.message);
}
function downloadPackageUsingArtifactTool(downloadDir: string, options: artifactToolRunner.IArtifactToolOptions, execOptions: IExecOptions) {
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));
}