本文整理汇总了TypeScript中azure-pipelines-task-lib/task.getInput函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getInput函数的具体用法?TypeScript getInput怎么用?TypeScript getInput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getInput函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: searchAndReplace
function searchAndReplace(value: string): string {
const method = tl.getInput("searchReplaceMethod", true);
const search = tl.getInput("searchValue") || "";
const replacement = tl.getInput("replacementValue") || "";
if (method === "basic") {
return value.split(search).join(replacement);
} else {
const regexOptions = tl.getInput("regexOptions", false);
let searchExpression: RegExp;
if (regexOptions) {
searchExpression = new RegExp(search, regexOptions);
} else {
searchExpression = new RegExp(search);
}
if (method === "match") {
const result = value.match(searchExpression);
if (!result || result.length === 0) {
tl.warning("Found no matches");
return "";
} else {
return result[0];
}
}
if (method === "regex") {
return value.replace(searchExpression, replacement);
}
}
return value;
}
示例2: promiseRetry
await common.runTfx(async tfx => {
try
{
tfx.arg(["extension", "isvalid", "--json", "--no-color"]);
common.setTfxMarketplaceArguments(tfx);
common.validateAndSetTfxManifestArguments(tfx);
const options = {
retries: +tl.getInput("maxRetries", false) || 10,
factor: 1,
minTimeout: 1000 * 60 * (+tl.getInput("minTimeout", false) || 1),
maxTimeout: 1000 * 60 * (+tl.getInput("maxTimeout", false) || 15),
randomize: false
};
await promiseRetry(options,
(retry, attempt) => {
tl.debug(`Attempt: ${attempt}`);
const result = tfx.execSync({ silent: false, failOnStdErr: false } as any);
const json = JSON.parse(result.stdout);
switch (json.status) {
case "pending":
return retry(json.status);
case "success":
return json.status;
default:
throw json.status;
}
});
tl.setResult(tl.TaskResult.Succeeded, "Extension is valid.");
} catch (err) {
tl.setResult(tl.TaskResult.Failed, `Extension validation failed: ${err}`);
}
});
示例3: run
async function run() {
try {
if (action === 'Build module images') {
console.log(tl.loc('BuildingModules'));
await BuildImage.run();
console.log(tl.loc('BuildingModulesFinished'));
} else if (action === 'Push module images') {
console.log(tl.loc('PushingModules'));
telemetryEvent.isACR = tl.getInput("containerregistrytype", true) === "Azure Container Registry";
await PushImage.run();
console.log(tl.loc('PushingModulesFinished'));
} else if (action === 'Deploy to IoT Edge devices') {
console.log(tl.loc('StartDeploy'));
telemetryEvent.hashIoTHub = util.sha256(tl.getInput("iothubname", true));
await DeployImage.run(telemetryEvent);
console.log(tl.loc('FinishDeploy'));
}
telemetryEvent.isSuccess = true;
tl.setResult(tl.TaskResult.Succeeded, "");
} catch (e) {
telemetryEvent.isSuccess = false;
tl.setResult(tl.TaskResult.Failed, e)
} finally {
telemetryEvent.taskTime = (+new Date() - (+startTime)) / 1000;
if (telemetryEnabled) {
trackEvent(action, telemetryEvent);
}
commonTelemetry.emitTelemetry('TaskEndpointId', "AzureIoTEdgeV2", telemetryEvent);
}
}
示例4: isServerBasedRun
function isServerBasedRun(): boolean {
const batchType = tl.getInput('distributionBatchType');
if (batchType && batchType === 'basedOnTestCases') {
const batchSize = tl.getInput('batchingBasedOnAgentsOption');
if (batchSize && batchSize === 'customBatchSize') {
return true;
}
} else if (batchType && batchType === 'basedOnExecutionTime') {
return true;
} else if (batchType && batchType === 'basedOnAssembly') {
return true;
}
const testType = tl.getInput('testSelector');
tl.debug('Value of Test Selector :' + testType);
if (testType.toLowerCase() === 'testplan' || testType.toLowerCase() === 'testrun') {
return true;
}
const parallelExecution = tl.getVariable('System.ParallelExecutionType');
tl.debug('Value of ParallelExecutionType :' + parallelExecution);
if (parallelExecution && parallelExecution.toLowerCase() === 'multimachine') {
const dontDistribute = tl.getBoolInput('dontDistribute');
if (dontDistribute) {
return false;
}
return true;
}
return false;
}
示例5: main
async function main(): Promise<void> {
var feed = getProjectAndFeedIdFromInputParam("feed");
if(feed.projectId) {
throw new Error(tl.loc("UnsupportedProjectScopedFeeds"));
}
let feedId = feed.feedId;
let regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
let packageId = tl.getInput("definition");
if(!regexGuid.test(packageId)){
packageId = "Nuget_" + tl.getInput("definition");
}
let version = tl.getInput("version");
let downloadPath = tl.getInput("downloadPath");
let collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri");
var accessToken = getAuthToken();
var credentialHandler = vsts.getBearerHandler(accessToken);
var vssConnection = new vsts.WebApi(collectionUrl, credentialHandler);
var coreApi = vssConnection.getCoreApi();
const retryLimitValue: string = tl.getVariable("VSTS_HTTP_RETRY");
const retryLimit: number = (!!retryLimitValue && !isNaN(parseInt(retryLimitValue))) ? parseInt(retryLimitValue) : 4;
tl.debug(`RetryLimit set to ${retryLimit}`);
await executeWithRetries("downloadPackage", () => downloadPackage(collectionUrl, accessToken, credentialHandler, feedId, packageId, version, downloadPath).catch((reason) => {
throw reason;
}), retryLimit);
}
示例6: usePythonVersion
(async () => {
try {
task.setResourcePath(path.join(__dirname, 'task.json'));
await usePythonVersion({
versionSpec: task.getInput('versionSpec', true),
addToPath: task.getBoolInput('addToPath', true),
architecture: task.getInput('architecture', true)
},
getPlatform());
task.setResult(task.TaskResult.Succeeded, "");
} catch (error) {
task.setResult(task.TaskResult.Failed, error.message);
}
})();
示例7:
var jarsigning = (fn: string) => {
// file must exist
tl.checkPath(fn, 'file to sign');
var jarsigner = tl.which("jarsigner", false);
if (!jarsigner) {
var java_home = tl.getVariable('JAVA_HOME');
if (!java_home) {
throw tl.loc('JavaHomeNotSet');
}
jarsigner = tl.resolve(java_home, 'bin', 'jarsigner');
}
var jarsignerRunner = tl.tool(jarsigner);
// Get keystore file path for signing
var keystoreFile = tl.getTaskVariable('KEYSTORE_FILE_PATH');
// Get keystore alias
var keystoreAlias = tl.getInput('keystoreAlias', true);
var keystorePass = tl.getInput('keystorePass', false);
var keyPass = tl.getInput('keyPass', false);
var jarsignerArguments = tl.getInput('jarsignerArguments', false);
jarsignerRunner.arg(['-keystore', keystoreFile]);
if (keystorePass) {
jarsignerRunner.arg(['-storepass', keystorePass]);
}
if (keyPass) {
jarsignerRunner.arg(['-keypass', keyPass]);
}
if (jarsignerArguments) {
jarsignerRunner.line(jarsignerArguments);
}
var unsignedFn = fn + ".unsigned";
var success = tl.mv(fn, unsignedFn, '-f', false);
jarsignerRunner.arg(['-signedjar', fn, unsignedFn, keystoreAlias]);
return jarsignerRunner.exec(null);
}
示例8: run
async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
// Check platform is macOS since demands are not evaluated on Hosted pools
if (os.platform() !== 'darwin') {
console.log(tl.loc('InstallRequiresMac'));
} else {
let keychain: string = tl.getInput('keychain');
let keychainPath: string = tl.getTaskVariable('APPLE_CERTIFICATE_KEYCHAIN');
let deleteCert: boolean = tl.getBoolInput('deleteCert');
let hash: string = tl.getTaskVariable('APPLE_CERTIFICATE_SHA1HASH');
if (deleteCert && hash) {
sign.deleteCert(keychainPath, hash);
}
let deleteKeychain: boolean = false;
if (keychain === 'temp') {
deleteKeychain = true;
} else if (keychain === 'custom') {
deleteKeychain = tl.getBoolInput('deleteCustomKeychain');
}
if (deleteKeychain && keychainPath) {
await sign.deleteKeychain(keychainPath);
}
}
} catch (err) {
tl.warning(err);
}
}
示例9: run
async function run() {
try {
// Configure localization
tl.setResourcePath(path.join(__dirname, 'task.json'));
// Get files to be signed
const filesPattern: string = tl.getInput('files', true);
// Signing the APK?
const apksign: boolean = tl.getBoolInput('apksign');
// Zipaligning the APK?
const zipalign: boolean = tl.getBoolInput('zipalign');
// Resolve files for the specified value or pattern
const filesToSign: string[] = tl.findMatch(null, filesPattern);
// Fail if no matching files were found
if (!filesToSign || filesToSign.length === 0) {
throw new Error(tl.loc('NoMatchingFiles', filesPattern));
}
for (const file of filesToSign) {
if (zipalign) {
await zipaligning(file);
}
if (apksign) {
await apksigning(file);
}
}
} catch (err) {
tl.setResult(tl.TaskResult.Failed, err);
}
}
示例10: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, 'task.json'));
let packagingLocation: pkgLocationUtils.PackagingLocation;
try {
packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.Npm);
} catch (error) {
tl.debug('Unable to get packaging URIs, using default collection URI');
tl.debug(JSON.stringify(error));
const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri');
packagingLocation = {
PackagingUris: [collectionUrl],
DefaultPackagingUri: collectionUrl
};
}
const forcedUrl = tl.getVariable('Npm.PackagingCollectionUrl');
if (forcedUrl) {
packagingLocation.DefaultPackagingUri = forcedUrl;
packagingLocation.PackagingUris.push(forcedUrl);
}
await _logNpmStartupVariables(packagingLocation);
const command = tl.getInput(NpmTaskInput.Command);
switch (command) {
case NpmCommand.Install:
return npmCustom.run(packagingLocation, NpmCommand.Install);
case NpmCommand.Publish:
return npmPublish.run(packagingLocation);
case NpmCommand.Custom:
return npmCustom.run(packagingLocation);
default:
tl.setResult(tl.TaskResult.Failed, tl.loc('UnknownCommand', command));
return;
}
}
示例11: installVsTestPlatformToolFromCustomFeed
// Installs the test platform from a custom feed provided by the user along with credentials for authentication against said feed
public async installVsTestPlatformToolFromCustomFeed(packageSource: string, versionSelectorInput: string, testPlatformVersion: string, username: string, password: string) {
let tempConfigFilePath = null;
try {
try {
if (!helpers.isNullEmptyOrUndefined(password)) {
tl.debug('Attempting to write feed details along with provided credentials to temporary config file.');
tempConfigFilePath = helpers.GenerateTempFile(`${uuid.v1()}.config`);
const feedId = uuid.v1();
this.prepareNugetConfigFile(packageSource, tempConfigFilePath, username, password, feedId);
packageSource = feedId;
ci.addToConsolidatedCi('passwordProvided', 'true');
ci.addToConsolidatedCi('usernameProvided', `${!helpers.isNullEmptyOrUndefined(username)}`);
} else {
packageSource = tl.getInput(constants.customFeed);
tl.debug(`Credentials were not provided. Skipping writing to config file. Will use custom package feed provided by user ${packageSource}`);
}
} catch (error) {
tl.error(error);
console.log(tl.loc('LatestStableCached'));
// Look for the latest stable version available in the cache as a fallback.
testPlatformVersion = 'x';
tempConfigFilePath = null;
}
await this.installVsTestPlatformToolFromSpecifiedFeed(packageSource, testPlatformVersion, versionSelectorInput, tempConfigFilePath);
} finally {
helpers.cleanUpTempConfigFile(tempConfigFilePath);
}
}
示例12: findAndroidTool
const apksigning = (fn: string) => {
// file must exist
tl.checkPath(fn, 'file to sign');
let apksigner = tl.getInput('apksignerLocation', false);
// if the tool path is not set, let's find one (anyone) from the SDK folder
if (!apksigner) {
apksigner = findAndroidTool('apksigner');
}
const apksignerRunner = tl.tool(apksigner);
// Get keystore file path for signing
const keystoreFile = tl.getTaskVariable('KEYSTORE_FILE_PATH');
// Get keystore alias
const keystoreAlias = tl.getInput('keystoreAlias', true);
const keystorePass = tl.getInput('keystorePass', false);
const keyPass = tl.getInput('keyPass', false);
const apksignerArguments = tl.getInput('apksignerArguments', false);
apksignerRunner.arg(['sign', '--ks', keystoreFile]);
if (keystorePass) {
apksignerRunner.arg(['--ks-pass', 'pass:' + keystorePass]);
}
if (keystoreAlias) {
apksignerRunner.arg(['--ks-key-alias', keystoreAlias]);
}
if (keyPass) {
apksignerRunner.arg(['--key-pass', 'pass:' + keyPass]);
}
if (apksignerArguments) {
apksignerRunner.line(apksignerArguments);
}
apksignerRunner.arg([fn]);
return apksignerRunner.exec(null);
};
示例13: run
async function run() {
tl.setResourcePath(path.join(__dirname, 'task.json'));
let indexFile = path.join(tl.getVariable("SAVE_NPMRC_PATH"), 'index.json');
if (tl.exist(indexFile)) {
let indexFileText = fs.readFileSync(indexFile, 'utf8');
let jsonObject = JSON.parse(indexFileText);
let npmrcIndex = JSON.stringify(jsonObject[tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile)]);
util.restoreFileWithName(tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile), npmrcIndex, tl.getVariable("SAVE_NPMRC_PATH"));
console.log(tl.loc("RevertedChangesToNpmrc", tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile)));
if (fs.readdirSync(tl.getVariable("SAVE_NPMRC_PATH")).length == 1) {
tl.rmRF(tl.getVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY"));
}
}
else {
console.log(tl.loc("NoIndexJsonFile"));
}
}
示例14: getRegistryAuthenticationToken
function getRegistryAuthenticationToken(): RegistryCredential {
// get the registry server authentication provider
var registryType: string = tl.getInput("containerregistrytype", true);
let token: RegistryCredential;
if (registryType == "Azure Container Registry") {
let acrObject: ACRRegistry = JSON.parse(tl.getInput("azureContainerRegistry"));
token = RegistryCredentialFactory.fetchACRCredential(tl.getInput("azureSubscriptionEndpoint"), acrObject);
}
else {
token = RegistryCredentialFactory.fetchGenericCredential(tl.getInput("dockerRegistryEndpoint"));
}
if (token == null || token.username == null || token.password == null || token.serverUrl == null) {
throw Error(tl.loc('ContainerRegistryInvalid', JSON.stringify(token)));
}
return token;
}
示例15: isMultiConfigOnDemandRun
function isMultiConfigOnDemandRun(): boolean {
const testType = tl.getInput('testSelector');
const parallelExecution = tl.getVariable('System.ParallelExecutionType');
if (testType && testType.toLowerCase() === 'testrun' && parallelExecution && parallelExecution.toLowerCase() === 'multiconfiguration') {
return true;
}
return false;
}