function performDeployTask()

in Tasks/codepush-release-cordova/codepush-release-cordova.js [59:130]


function performDeployTask(accessKey, appName, appStoreVersion, platform, deploymentName, description, rollout, isMandatory, isDisabled, shouldBuild) {
    var cwd = tl.getVariable("BUILD_SOURCEDIRECTORY", false) || tl.getVariable("BUILD_SOURCESDIRECTORY", false);
    tl.debug("Swapping to working directory: " + cwd);
    process.chdir(cwd);

    if (process.cwd() != cwd) {
        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.
    try {
        ensureLoggedOut();
    } catch (e) {
        // not logged in
    }


    // Log in to the CodePush CLI.
    executeCommandAndHandleResult("login", /*positionArgs*/ null, { accessKey: accessKey });

    // Always pull a local cordova. This is to work around a point in time issue with the hosted agents having a broken globally resolved cordova command.
    var originalPath = process.env["PATH"];
    process.env["PATH"] = path.join(process.cwd(), "node_modules", ".bin") + (process.platform == "win32" ? ";" : ":") + originalPath;
    console.log("Installing local cordova cli...");
    execSync("npm install cordova", { stdio: "inherit" });

    // Run release command.
    executeCommandAndHandleResult(
        "release-cordova",
        [appName, platform],
        {
            targetBinaryVersion: (appStoreVersion == "autodetect" ? false : appStoreVersion),
            deploymentName: deploymentName,
            description: description,
            rollout: rollout,
            mandatory: isMandatory,
            disabled: isDisabled,
            build: shouldBuild
        }
    );

    // Log out.
    ensureLoggedOut();
}