How to use the azure-pipelines-task-lib/task.TaskResult function in azure-pipelines-task-lib

To help you get started, we’ve selected a few azure-pipelines-task-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jfrog / artifactory-vsts-extension / tasks / ArtifactoryGenericDownload / Ver1 / downloadArtifacts.js View on Github external
try {
        utils.executeCliCommand(cliCommand, workDir);

    } catch (executionException) {
        tl.setResult(tl.TaskResult.Failed, executionException);
    } finally {
        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, "Download Succeeded.");
}
github microsoft / azure-devops-extension-tasks / BuildTasks / PublishExtension / PublishExtension.ts View on Github external
await common.checkUpdateTasksManifests();
        } else {
            // Set vsix file argument
            let vsixFilePattern = tl.getPathInput("vsixFile", true);
            let matchingVsixFile: string[];
            if (vsixFilePattern.indexOf("*") >= 0 || vsixFilePattern.indexOf("?") >= 0) {
                tl.debug("Pattern found in vsixFile parameter");
                matchingVsixFile = tl.findMatch(tl.getInput("cwd", false) || process.cwd(), vsixFilePattern);
            }
            else {
                tl.debug("No pattern found in vsixFile parameter");
                matchingVsixFile = [vsixFilePattern];
            }

            if (!matchingVsixFile || matchingVsixFile.length === 0) {
                tl.setResult(tl.TaskResult.Failed, `Found no vsix files matching: ${vsixFilePattern}.`);
                return false;
            }
            if (matchingVsixFile.length !== 1) {
                tl.setResult(tl.TaskResult.Failed, `Found multiple vsix files matching: ${vsixFilePattern}.`);
                return false;
            }

            const vsixFile = matchingVsixFile[0];
            tl.checkPath(vsixFile, "vsixPath");

            vsixOutput = tl.getVariable("System.DefaultWorkingDirectory");

            const publisher = tl.getInput("publisherId", false);

            const extensionId = tl.getInput("extensionId", false);
            const extensionTag = tl.getInput("extensionTag", false);
github jfrog / artifactory-vsts-extension / tasks / ArtifactoryMaven / mavenBuild.js View on Github external
function cleanup(cliPath, workDir) {
    // Delete servers.
    try {
        utils.deleteCliServers(cliPath, workDir, [serverIdDeployer, serverIdResolver]);
    } catch (deleteServersException) {
        tl.setResult(tl.TaskResult.Failed, deleteServersException);
    }
    // Remove extractor variables.
    try {
        removeExtractorDownloadVariables(cliPath, workDir);
    } catch (removeVariablesException) {
        tl.setResult(tl.TaskResult.Failed, removeVariablesException);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / VsTestPlatformToolInstallerV1 / vstestplatformtoolinstaller.ts View on Github external
case 'customfeed':
                tl.debug('Going via custom feed download flow.');
                await new NugetFeedInstaller()
                    .installVsTestPlatformToolFromCustomFeed(packageSource, versionSelectorInput, testPlatformVersion, username, password);
            break;

            case 'netshare':
                tl.debug('Going via net share copy flow.');
                await new NetworkShareInstaller().installVsTestPlatformToolFromNetworkShare(networkSharePath);
                break;
        }

    } catch (error) {
        ci.publishEvent('Completed', { isSetupSuccessful: 'false' } );
        tl.setResult(tl.TaskResult.Failed, error);
        return;
    }

    ci.addToConsolidatedCi('result', constants.installationStatusSucceeded);
}
github rdagumampan / yuniql / yuniql-azure-pipelines / src / install / useyuniql.ts View on Github external
async function run() {
    try {
        //get target version
        const version = taskLib.getInput('version', false);
        console.log('yuniql/input_version: ' + version);
        if (version) {
            await installer.getYuniql(version, true);
        }
    }
    catch (error) {
        console.log('yuniql/error: ' + error.message);
        taskLib.setResult(taskLib.TaskResult.Failed, error.message);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / AzureMonitorAlertsV0 / azuremonitoralerts.ts View on Github external
console.log("##vso[task.logissue type=warning]" + tl.loc("DeprecatedTask"));
		
		let connectedServiceName: string = tl.getInput("ConnectedServiceName", true);
		let resourceGroupName: string = tl.getInput("ResourceGroupName", true);
		let resourceType: string = tl.getInput("ResourceType", true);
		let resourceName: string = tl.getInput("ResourceName", true);
		let alertRules: IAzureMetricAlertRulesList = JSON.parse(tl.getInput("AlertRules", true));
		let notifyServiceOwners: boolean = tl.getInput("NotifyServiceOwners") && tl.getInput("NotifyServiceOwners").toLowerCase() === "true" ? true : false;
		let notifyEmails: string = tl.getInput("NotifyEmails");

		var azureEndpoint: AzureEndpoint = await new AzureRMEndpoint(connectedServiceName).getEndpoint();
		let azureMonitorAlertsUtility :AzureMonitorAlertsUtility = new AzureMonitorAlertsUtility(azureEndpoint, resourceGroupName, resourceType, resourceName);
		await azureMonitorAlertsUtility.addOrUpdateAlertRules(alertRules.rules, notifyServiceOwners, notifyEmails);
	}
	catch (error) {
		tl.setResult(tl.TaskResult.Failed, error);
	}
}
github microsoft / azure-pipelines-tasks / Tasks / InstallSSHKeyV0 / postinstallsshkey.ts View on Github external
async function run() {
    try {
        util.tryRestoreKnownHosts();

        let agentPid: string = tl.getTaskVariable(util.postKillAgentSetting);
        if (agentPid) {
            tl.debug('Killing SSH Agent PID: ' + agentPid);
            ps.kill(+agentPid);
        } else {
            let deleteKey: string = tl.getTaskVariable(util.postDeleteKeySetting);
            let sshTool: util.SshToolRunner = new util.SshToolRunner();
            sshTool.deleteKey(deleteKey)
        }
    } catch (err) {
        tl.setResult(tl.TaskResult.Failed, err);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / DownloadPackageV0 / download.ts View on Github external
	.catch((error) => tl.setResult(tl.TaskResult.Failed, error));
github microsoft / azure-pipelines-tasks / Tasks / UseDotNetV2 / Tests / usedotnetTests.ts View on Github external
getPathInput: function (inputName: string, required: boolean): string {
        if (inputName == "workingDirectory") {

            return "";
        }
        return "";
    },
    setResult: function (result: tl.TaskResult, message: string): void {
        tl.setResult(result, message);
    },
    setVariable: function (name: string, value: string, secret?: boolean) {
        tl.setVariable(name, value, secret ? true : false);
    },
    TaskResult: {
        Failed: tl.TaskResult.Failed,
        Succeeded: tl.TaskResult.Succeeded
    }
});

mockery.registerMock('./versionfetcher', {
    DotNetCoreVersionFetcher: function () {
        return {
            getVersionInfo: function (versionSpec: string, packageType: string, includePreviewVersions: boolean): Promise {
                if (process.env["__case__"] == "matchingversionnotfound") {
                    return new Promise((resolve, reject) => {
                        resolve(null);
                    });
                }

                return new Promise((resolve, reject) => {
                    resolve(new VersionInfo(JSON.parse(`{"version":"2.1.0", "runtime-version":"2.1.100", "files":[{"name":"win-x64.zip", "url":"https://pathToWin/zip", "rid":"win-x64"}]}`), "sdk"));
                });
github microsoft / azure-pipelines-tasks / Tasks / DownloadPackageV1 / main.ts View on Github external
    .catch(error => tl.setResult(tl.TaskResult.Failed, error));