本文整理匯總了TypeScript中vso-node-api/WebApi.getBasicHandler函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getBasicHandler函數的具體用法?TypeScript getBasicHandler怎麽用?TypeScript getBasicHandler使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getBasicHandler函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(username: string, password?: string) {
if (password !== undefined) {
// NTLM or Basic
} else {
// Personal Access Token
this._credentialHandler = getBasicHandler("OAuth", username);
}
}
示例2: constructor
constructor(username: string, password?: string, domain?: string, workstation?: string) {
if (username !== undefined && password !== undefined) {
// NTLM (we don't support Basic auth)
this._credentialHandler = getNtlmHandler(username, password, domain, workstation);
} else {
// Personal Access Token (use username since it is first argument to constructor)
this._credentialHandler = getBasicHandler(Constants.OAuth, username);
}
}
示例3: getConnectionData
function getConnectionData(uri: string, username: string, password: string): Q.Promise<locationApi.ConnectionData> {
const defer = Q.defer<locationApi.ConnectionData>();
new locationApi.LocationApi(uri, [vstsWebApi.getBasicHandler(username, password)])
.getConnectionData((err: any, statusCode: number, connectionData: locationApi.ConnectionData) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(connectionData);
}
});
return defer.promise;
}
示例4: constructor
constructor(username: string, password?: string, domain?: string, workstation?: string) {
if (username !== undefined && password !== undefined) {
// NTLM (we don't support Basic auth)
this._username = username;
this._password = password;
this._domain = domain;
this._workstation = workstation;
this._credentialHandler = getNtlmHandler(this._username, this._password, this._domain, this._workstation);
} else {
// Personal Access Token
this._username = Constants.OAuth;
this._password = username; //use username since it is first argument to constructor
this._credentialHandler = getBasicHandler(this._username, this._password);
}
}
示例5: getBasicHandler
var promise = new Promise<void>(async (resolve, reject) => {
var connection = tl.getInput("connection", true);
var projectId = tl.getInput("project", true);
var definitionId = tl.getInput("definition", true);
var buildId = tl.getInput("version", true);
var itemPattern = tl.getInput("itemPattern", true);
var downloadPath = tl.getInput("downloadPath", true);
var endpointUrl = tl.getEndpointUrl(connection, false);
var username = tl.getEndpointAuthorizationParameter(connection, 'username', true);
var accessToken = tl.getEndpointAuthorizationParameter(connection, 'apitoken', true)
|| tl.getEndpointAuthorizationParameter(connection, 'password', true);
var credentialHandler = getBasicHandler(username, accessToken);
var vssConnection = new WebApi(endpointUrl, credentialHandler);
var debugMode = tl.getVariable('System.Debug');
var verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
var parallelLimit: number = +tl.getVariable("release.artifact.download.parallellimit");
var templatePath = path.join(__dirname, 'vsts.handlebars');
var buildApi = vssConnection.getBuildApi();
var artifacts = await executeWithRetries("getArtifacts", () => buildApi.getArtifacts(parseInt(buildId), projectId), 3).catch((reason) => {
reject(reason);
});
if (artifacts) {
var downloadPromises: Array<Promise<any>> = [];
console.log("Linked artifacts count: " + artifacts.length);
artifacts.forEach(async function (artifact, index, artifacts) {
let downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = itemPattern;
downloaderOptions.verbose = verbose;
if (parallelLimit) {
downloaderOptions.parallelProcessingLimit = parallelLimit;
}
if (artifact.resource.type.toLowerCase() === "container") {
let downloader = new engine.ArtifactEngine();
var containerParts: string[] = artifact.resource.data.split('/', 3);
if (containerParts.length !== 3) {
throw new Error(tl.loc("FileContainerInvalidArtifactData"));
}
var containerId: number = parseInt(containerParts[1]);
var containerPath: string = containerParts[2];
var itemsUrl = endpointUrl + "/_apis/resources/Containers/" + containerId + "?itemPath=" + encodeURIComponent(containerPath) + "&isShallow=true";
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
console.log(tl.loc("DownloadArtifacts", itemsUrl));
var variables = {};
var handler = username ? new webHandlers.BasicCredentialHandler(username, accessToken) : new webHandlers.PersonalAccessTokenCredentialHandler(accessToken);
var webProvider = new providers.WebProvider(itemsUrl, templatePath, variables, handler);
var fileSystemProvider = new providers.FilesystemProvider(downloadPath);
downloadPromises.push(downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).catch((reason) => {
reject(reason);
}));
}
else if (artifact.resource.type.toLowerCase() === "filepath") {
let downloader = new engine.ArtifactEngine();
let downloadUrl = artifact.resource.data;
let artifactLocation = downloadUrl + '/' + artifact.name;
if (!fs.existsSync(artifactLocation)) {
console.log(tl.loc("ArtifactNameDirectoryNotFound", artifactLocation, downloadUrl));
artifactLocation = downloadUrl;
}
console.log(tl.loc("DownloadArtifacts", artifactLocation));
var fileShareProvider = new providers.FilesystemProvider(artifactLocation);
var fileSystemProvider = new providers.FilesystemProvider(downloadPath + '\\' + artifact.name);
downloadPromises.push(downloader.processItems(fileShareProvider, fileSystemProvider, downloaderOptions).catch((reason) => {
reject(reason);
}));
}
else {
console.log(tl.loc('UnsupportedArtifactType', artifact.resource.type));
}
});
Promise.all(downloadPromises).then(() => {
console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
resolve();
}).catch((error) => {
reject(error);
});
}
});
示例6: run
async function run() {
try {
tl.debug("Starting Coverage Gate task");
var tpcUri = tl.getVariable("System.TeamFoundationCollectionUri");
var teamProject = tl.getVariable("System.TeamProject");
var buildId = parseInt(tl.getVariable("Build.BuildId"));
var minDelta = parseInt(tl.getInput("minDelta", true));
var operator = tl.getInput("operator", true);
var username = tl.getInput("username", false);
var password = tl.getInput("password", false);
tl.debug(`minDelta: ${minDelta}`);
tl.debug(`operator: ${operator}`);
tl.debug(`username: ${username}`);
// handle creds
var credOk = true;
var credHandler: vstsInterfaces.IRequestHandler;
var accessToken = tl.getVariable("System.AccessToken");
if (!accessToken || accessToken.length === 0) {
if (username && username.length > 0) {
tl.debug("Detected username: creating basic cred handler");
credHandler = webApi.getBasicHandler(username, password);
} else {
tl.setResult(tl.TaskResult.Failed, "Could not find token for autheniticating. Please enable OAuth token in Build/Release Options or supply username/password.");
credOk = false;
}
} else {
tl.debug("Detected token: creating bearer cred handler");
credHandler = webApi.getBearerHandler(accessToken);
}
if (credOk) {
var vsts = new webApi.WebApi(tpcUri, credHandler);
// get previous successful builds
tl.debug("Connecting to test API");
var testApi = vsts.getTestApi();
tl.debug("Getting coverage data");
// 1 = modules, 2 = function, 4 = block
var covData = await testApi.getCodeCoverageSummary(teamProject, buildId);
tl.debug("Analyzing coverage data");
if (covData) {
var data = covData.coverageData[0];
var trends = data.coverageStats.filter(c => c.isDeltaAvailable)
.map(u => {
return {
Label: u.label,
Delta: u.delta
};
});
if (trends.length === 0){
tl.setResult(tl.TaskResult.Failed, `There are no coverage deltas. Make sure you have at least 2 builds.`);
}
var fail = trends.some(t => operator === 'lt' ? t.Delta < minDelta : t.Delta <= minDelta);
if (fail) {
tl.setResult(tl.TaskResult.Failed, `Coverage delta is below the threshold of ${minDelta}`);
}
} else {
tl.setResult(tl.TaskResult.Failed, "No coverage data for build. Cannot determine trend.");
}
tl.setResult(tl.TaskResult.Succeeded, `Code coverage delta is above the threshold of ${minDelta}`);
}
} catch (err) {
tl.debug("Caught an error - logging");
let msg = err;
if (err.message) {
msg = err.message;
}
tl.setResult(tl.TaskResult.Failed, msg);
}
tl.debug("Leaving Coverage Gate task");
}
示例7: getRawGalleryAPI
export function getRawGalleryAPI(pat: string): IGalleryApi {
const authHandler = getBasicHandler('oauth', pat);
const vsoapi = new WebApi('oauth', authHandler);
return vsoapi.getGalleryApi('https://marketplace.visualstudio.com');
}