How to use the azure-pipelines-task-lib/task.debug 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 / DotNetCoreInstallerV1 / versionfetcher.ts View on Github external
var latestChannelVersion: string = `${versionParts.majorVersion}.0`;
            this.channels.forEach(channel => {
                // todo: should also check if the channel is in preview state, if so then only select the channel if includePreviewVersion should be true.
                // As a channel with state in preview will only have preview releases.
                // example: versionSpec: 3.x Channels: 3.0 (current), 3.1 (preview).
                // if (includePreviewVersion == true) select 3.1
                // else select 3.0
                if (utils.compareChannelVersion(channel.channelVersion, latestChannelVersion) > 0 && channel.channelVersion.startsWith(versionParts.majorVersion)) {
                    latestChannelVersion = channel.channelVersion;
                }
            });

            requiredChannelVersion = latestChannelVersion;
        }

        tl.debug(tl.loc("RequiredChannelVersionForSpec", requiredChannelVersion, versionSpec));
        return this.channels.find(channel => {
            if (channel.channelVersion == requiredChannelVersion) {
                return true
            }
        });
    }
github microsoft / azure-pipelines-tasks / Tasks / Common / packaging-common / nuget / NuGetExeXmlHelper.ts View on Github external
AddSourceToNuGetConfig(name: string, source: string, username?: string, password?: string): void {
        let nugetTool = ngToolRunner.createNuGetToolRunner(this._nugetPath, this._environmentSettings, this._authInfo);
        nugetTool.arg("sources");
        nugetTool.arg("Add");
        nugetTool.arg("-NonInteractive");
        nugetTool.arg("-Name");
        nugetTool.arg(name);
        nugetTool.arg("-Source");
        nugetTool.arg(source);
        nugetTool.arg("-ConfigFile");
        nugetTool.arg(this._nugetConfigPath);

        if (username || password) {
            if (!username || !password) {
                tl.debug('Adding NuGet source with username and password, but one of them is missing.');
            }

            nugetTool.arg("-Username");
            nugetTool.arg(username);
            nugetTool.arg("-Password");
            nugetTool.arg(password);

            if (!CommandHelper.isWindowsAgent()) {
                // only Windows supports DPAPI. Older NuGets fail to add credentials at all if DPAPI fails.
                nugetTool.arg("-StorePasswordInClearText");
            }
        }

        // short run, use execSync
        nugetTool.execSync();
    }
github microsoft / azure-pipelines-tasks / Tasks / VsTestV2 / helpers.ts View on Github external
public static setConsoleCodePage() {
        tl.debug("Changing active code page to UTF-8");
        const chcp = tl.tool(path.resolve(process.env.windir, "system32", "chcp.com"));
        chcp.arg(["65001"]);
        chcp.execSync({ silent: true } as tr.IExecSyncOptions);
    }
github microsoft / azure-pipelines-tasks / Tasks / AzureNLBManagementV1 / nlbazureutility.ts View on Github external
var deferred = Q.defer();
	var envAuthUrl = (SPN.envAuthUrl) ? SPN.envAuthUrl : defaultAuthUrl;
	var authorityUrl = envAuthUrl + SPN.tenantID + "/oauth2/token/";

	var post_data = querystring.stringify({
		resource: endpointUrl, 
		client_id: SPN.servicePrincipalClientID,
		grant_type: "client_credentials", 
		client_secret: SPN.servicePrincipalKey
	});

	var requestHeader = {
		"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
	};

	tl.debug(`Requesting for bearer token ${authorityUrl}`);
	httpObj.send("POST", authorityUrl, post_data, requestHeader, (error, response, body) => {
		if(error) {
			deferred.reject(error);
		}
		else if (response.statusCode == 200) {
			deferred.resolve(JSON.parse(body).access_token);
		}
		else {
			deferred.reject(tl.loc("CouldNotFetchAcessToken", response.statusCode, response.statusMessage, body));
		};
	}); 

    return deferred.promise;
}
github geeklearningio / gl-vsts-tasks-yarn / Tasks / Yarn / packaging / locationUtilities.ts View on Github external
}

  const accessToken = getSystemAccessToken();
  const areaId = getAreaIdForProtocol(protocolType);

  const serviceUri = await getServiceUriFromAreaId(
    collectionUrl,
    accessToken,
    areaId
  );

  const webApi = getWebApiWithProxy(serviceUri);

  const locationApi = await webApi.getLocationsApi();

  tl.debug("Acquiring Packaging endpoints from " + serviceUri);

  const connectionData = await locationApi.getConnectionData(
    interfaces.ConnectOptions.IncludeServices
  );

  tl.debug("Successfully acquired the connection data");
  const defaultAccessPoint: string = connectionData.locationServiceData.accessMappings.find(
    mapping =>
      mapping.moniker ===
      connectionData.locationServiceData.defaultAccessMappingMoniker
  ).accessPoint;

  pkgLocation.DefaultPackagingUri = defaultAccessPoint;
  pkgLocation.PackagingUris.push(defaultAccessPoint);
  pkgLocation.PackagingUris = pkgLocation.PackagingUris.concat(
    connectionData.locationServiceData.accessMappings.map(mapping => {
github microsoft / azure-pipelines-tasks / Tasks / VsTestV2 / settingshelper.ts View on Github external
parametersArray.forEach(function (parameter) {
            const key = parameter.$.Name || parameter.$.name;
            if (overrideParameters[key] && overrideParameters[key].value) {
                tl.debug('Overriding value for parameter : ' + key);
                if (parameter.$.Value) {
                    parameter.$.Value = overrideParameters[key].value;		
                } else {		
                    parameter.$.value = overrideParameters[key].value;		
                }
            }
        });
    }
github microsoft / azure-pipelines-tasks / Tasks / KubernetesManifestV0 / src / utils / DeploymentHelper.ts View on Github external
async function pushDeploymentDataToEvidenceStore(requestBody: string, requestUrl: string): Promise {
    const request = new WebRequest();
    const accessToken: string = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);
    request.uri = requestUrl;
    request.method = 'POST';
    request.body = requestBody;
    request.headers = {
        "Content-Type": "application/json",
        "Authorization": "Bearer " + accessToken
    };

    tl.debug("requestUrl: " + requestUrl);
    tl.debug("requestBody: " + requestBody);

    try {
        tl.debug("Sending request for pushing deployment data to Image meta data store");
        const response = await sendRequest(request);
        return response;
    }
    catch (error) {
        tl.debug("Unable to push to deployment details to Artifact Store, Error: " + error);
    }

    return Promise.resolve();
}
github microsoft / azure-pipelines-tasks / Tasks / Common / docker-common-v2 / containerconnection.ts View on Github external
public execCommand(command: tr.ToolRunner, options?: tr.IExecOptions) {
        let errlines = [];
        let dockerHostVar = tl.getVariable("DOCKER_HOST");
        if (dockerHostVar) {
            tl.debug(tl.loc('ConnectingToDockerHost', dockerHostVar));
        }

        command.on("errline", line => {
            errlines.push(line);
        });
        return command.exec(options).fail(error => {            
            if (dockerHostVar) {
                tl.warning(tl.loc('DockerHostVariableWarning', dockerHostVar));
            }

            errlines.forEach(line => tl.error(line));
            throw error;
        });
    }
github microsoft / google-play-vsts-extension / Tasks / google-play-release-bundle / GooglePlay.ts View on Github external
};

    const resource: googleutil.AndroidListingResource = {
        language: languageCode
    };

    for (const i in resourceParts) {
        if (resourceParts.hasOwnProperty(i)) {
            const file: string = path.join(directory, resourceParts[i]);
            try {
                const fileContents: Buffer = fs.readFileSync(file);
                resource[i] = fileContents.toString();
            } catch (e) {
                tl.debug(`Failed to read metadata file ${file}:`);
                tl.debug(e);
                tl.debug('Ignoring...');
            }
        }
    }

    tl.debug(`Finished constructing listing resource ${JSON.stringify(resource)}`);
    return resource;
}
github microsoft / google-play-vsts-extension / Tasks / google-play-release-bundle / GooglePlay.ts View on Github external
}
            });
        }

        tl.debug('Version codes to keep: ' + JSON.stringify(newTrackVersionCodes));
        if (newTrackVersionCodes.indexOf(bundleVersionCode) === -1) {
            newTrackVersionCodes.push(bundleVersionCode);
        }
    }

    tl.debug(`New ${track} track version codes: ` + JSON.stringify(newTrackVersionCodes));
    try {
        res = await googleutil.updateTrack(edits, packageName, track, newTrackVersionCodes, userFraction, releaseNotes);
    } catch (e) {
        tl.debug(`Failed to update track ${track}.`);
        tl.debug(e);
        throw new Error(tl.loc('CannotUpdateTrack', track, e));
    }
    return res;
}