How to use the azure-pipelines-task-lib/task.setResourcePath 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 microsoft / azure-pipelines-tasks / Tasks / UsePythonV1 / main.ts View on Github external
(async () => {
    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);
    }
github microsoft / azure-pipelines-tasks / Tasks / DownloadPackageV1 / main.ts View on Github external
var path = require("path");

import * as tl from "azure-pipelines-task-lib/task";
import * as nutil from "packaging-common/nuget/Utility";
import * as telemetry from "utility-common/telemetry";

import { PackageUrlsBuilder } from "./packagebuilder";
import { PackageFile } from "./packagefile";
import { getConnection } from "./connections";
import { Retry } from "./retry";
import { downloadUniversalPackage } from "./universal";
import { getProjectAndFeedIdFromInputParam } from "packaging-common/util"

tl.setResourcePath(path.join(__dirname, "task.json"));

async function main(): Promise {
    // Getting inputs.
    let packageType = tl.getInput("packageType");
    let projectFeed = tl.getInput("feed");
    let viewId = tl.getInput("view");
    let packageId = tl.getInput("definition");
    let version = tl.getInput("version");
    let downloadPath = tl.getInput("downloadPath");
    let filesPattern = tl.getInput("files");
    let extractPackage = tl.getInput("extract") === "true" && (packageType === "npm" || packageType === "nuget");

    // Getting variables.
    const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri");
    const retryLimitValue: string = tl.getVariable("VSTS_HTTP_RETRY");
    const retryLimit: number = !!retryLimitValue && !isNaN(parseInt(retryLimitValue)) ? parseInt(retryLimitValue) : 4;
github microsoft / azure-pipelines-tasks / Tasks / AzureFunctionOnKubernetesV0 / src / run.ts View on Github external
"use strict";

import * as path from 'path';
import * as tl from 'azure-pipelines-task-lib/task';
import * as utils from './utils/utilities';
import { deploy } from './deploy';
import { DockerConnection } from './dockerConnection';
import { CommandHelper } from './utils/commandHelper';

tl.setResourcePath(path.join(__dirname, "..", 'task.json'));

let telemetry = {
    jobId: tl.getVariable('SYSTEM_JOBID')
};

console.log("##vso[telemetry.publish area=%s;feature=%s]%s",
    "TaskEndpointId",
    "AzureFunctionOnKubernetesV0",
    JSON.stringify(telemetry));

async function run() {
    const commandHelper = new CommandHelper();
    const dockerConnection = new DockerConnection();
    const kubernetesConnection = utils.getKubernetesConnection();
    dockerConnection.open();
    kubernetesConnection.open();
github microsoft / azure-pipelines-tasks / Tasks / NuGetToolInstallerV1 / nugettoolinstaller.ts View on Github external
async function run() {
    try {
        taskLib.setResourcePath(path.join(__dirname, 'task.json'));

        const versionSpec = taskLib.getInput('versionSpec', false) || DEFAULT_NUGET_VERSION;
        const checkLatest = taskLib.getBoolInput('checkLatest', false);
        await nuGetGetter.getNuGet(versionSpec, checkLatest, true);
    } catch (error) {
        console.error('ERR:' + error.message);
        taskLib.setResult(taskLib.TaskResult.Failed, '');
    }
}
github microsoft / azure-pipelines-tasks / Tasks / AzureMonitorAlertsV0 / azuremonitoralerts.ts View on Github external
async function run() {
	try {
		tl.setResourcePath(path.join(__dirname, "task.json"));
		tl.setResourcePath(path.join( __dirname, 'node_modules/azure-arm-rest-v2/module.json'));

		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) {
github microsoft / azure-pipelines-tasks / Tasks / TwineAuthenticateV0 / authcleanup.ts View on Github external
async function run() {
    tl.setResourcePath(path.join(__dirname, "task.json"));
    const pypircPath = tl.getVariable("PYPIRC_PATH");
    if (tl.exist(pypircPath)) {
        tl.debug(tl.loc("Info_RemovingPypircFile", pypircPath));
        tl.rmRF(pypircPath);
    }
    else {
        console.log(tl.loc("NoPypircFile"));
    }
}
run();
github lukka / CppBuildTasks / task-vcpkg / src / vcpkg-task.ts View on Github external
async function main(): Promise {
  try {
    tl.setResourcePath(path.join(__dirname, 'task.json'));
    let runner: vcpkgrunner.VcpkgRunner = new vcpkgrunner.VcpkgRunner();
    await runner.run();
    tl.setResult(tl.TaskResult.Succeeded, tl.loc('vcpkgSucceeded'));
    return 0;
  } catch (err) {
    tl.debug('Error: ' + err);
    tl.error(err);
    tl.setResult(tl.TaskResult.Failed, tl.loc('vcpkgFailed', err));
    return -1000;
  }
}
github microsoft / azure-pipelines-tasks / Tasks / FtpUploadV2 / ftpuploadtask.ts View on Github external
async function run() {
    tl.setResourcePath(path.join(__dirname, "task.json"));

    const tries = 3;
    const ftpOptions: FtpOptions = getFtpOptions();

    if (!ftpOptions.serverEndpointUrl.protocol) {
        tl.setResult(tl.TaskResult.Failed, tl.loc("FTPNoProtocolSpecified"));
    }
    if (!ftpOptions.serverEndpointUrl.hostname) {
        tl.setResult(tl.TaskResult.Failed, tl.loc("FTPNoHostSpecified"));
    }

    const files: string[] = findFiles(ftpOptions);
    const tracker = new ProgressTracker(ftpOptions, files.length);
    if (files.length === 0) {
        tl.warning(tl.loc("NoFilesFound"));
        return;
github microsoft / azure-pipelines-tasks / Tasks / DownloadFileshareArtifactsV0 / main.ts View on Github external
var path = require('path');
var url = require('url');
var fs = require('fs');

import * as tl from 'azure-pipelines-task-lib/task';

import * as models from 'artifact-engine/Models';
import * as engine from 'artifact-engine/Engine';
import * as providers from 'artifact-engine/Providers';
import * as webHandlers from 'artifact-engine/Providers/typed-rest-client/Handlers';

var taskJson = require('./task.json');

tl.setResourcePath(path.join(__dirname, 'task.json'));

const area: string = 'DownloadFileShareArtifacts';

function getDefaultProps() {
    const hostType = (tl.getVariable('SYSTEM.HOSTTYPE') || "").toLowerCase();
    return {
        hostType: hostType,
        definitionName: '[NonEmail:' + (hostType === 'release' ? tl.getVariable('RELEASE.DEFINITIONNAME') : tl.getVariable('BUILD.DEFINITIONNAME')) + ']',
        processId: hostType === 'release' ? tl.getVariable('RELEASE.RELEASEID') : tl.getVariable('BUILD.BUILDID'),
        processUrl: hostType === 'release' ? tl.getVariable('RELEASE.RELEASEWEBURL') : (tl.getVariable('SYSTEM.TEAMFOUNDATIONSERVERURI') + tl.getVariable('SYSTEM.TEAMPROJECT') + '/_build?buildId=' + tl.getVariable('BUILD.BUILDID')),
        taskDisplayName: tl.getVariable('TASK.DISPLAYNAME'),
        jobid: tl.getVariable('SYSTEM.JOBID'),
        agentVersion: tl.getVariable('AGENT.VERSION'),
        agentOS: tl.getVariable('AGENT.OS'),
        agentName: tl.getVariable('AGENT.NAME'),
        version: taskJson.version
github lukka / CppBuildTasks / task-cmake / src / cmake-task.ts View on Github external
async function main(): Promise {
  try {
    tl.setResourcePath(path.join(__dirname, 'task.json'));
    let runner: cmakerunner.CMakeRunner = new cmakerunner.CMakeRunner();
    await runner.run();
    tl.setResult(tl.TaskResult.Succeeded, tl.loc('CMakeSuccess'));
    return;
  } catch (err) {
    tl.debug('Error: ' + err);
    tl.error(err);
    tl.setResult(tl.TaskResult.Failed, tl.loc('CMakeFailed', err));
    return;
  }
}