本文整理汇总了TypeScript中vsts-task-lib/toolrunner.ToolRunner.pipeExecOutputToTool方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolRunner.pipeExecOutputToTool方法的具体用法?TypeScript ToolRunner.pipeExecOutputToTool怎么用?TypeScript ToolRunner.pipeExecOutputToTool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vsts-task-lib/toolrunner.ToolRunner
的用法示例。
在下文中一共展示了ToolRunner.pipeExecOutputToTool方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getP12CommonName
export async function getP12CommonName(p12Path: string, p12Pwd: string) {
//openssl pkcs12 -in <p12Path> -nokeys -passin pass:"<p12Pwd>" | openssl x509 -noout –subject
let opensslPath: string = tl.which('openssl', true);
let openssl1: ToolRunner = tl.tool(opensslPath);
openssl1.arg(['pkcs12', '-in', p12Path, '-nokeys', '-passin', 'pass:' + p12Pwd]);
let openssl2: ToolRunner = tl.tool(opensslPath);
openssl2.arg(['x509', '-noout', '-subject']);
openssl1.pipeExecOutputToTool(openssl2);
let commonName: string;
openssl1.on('stdout', function (data) {
if (data) {
// find the subject
data = data.toString().trim();
let subject: string[] = data.match(/subject=.+\/CN=.+\(.+\).+/g);
if (subject && subject[0]) {
// find the CN from the subject
let cn: string[] = subject[0].trim().match(/\/CN=.+\(.+\)/g);
if (cn && cn[0]) {
commonName = cn[0].replace('/CN=', '').trim();
}
}
}
})
await openssl1.exec();
tl.debug('P12 common name (CN) = ' + commonName);
return commonName;
}
示例2: getP12CommonName
export async function getP12CommonName(p12Path: string, p12Pwd: string): Promise<string> {
//openssl pkcs12 -in <p12Path> -nokeys -passin pass:"<p12Pwd>" | openssl x509 -noout –subject
let opensslPath: string = tl.which('openssl', true);
let openssl1: ToolRunner = tl.tool(opensslPath);
if (!p12Pwd) {
// if password is null or not defined, set it to empty
p12Pwd = '';
}
openssl1.arg(['pkcs12', '-in', p12Path, '-nokeys', '-passin', 'pass:' + p12Pwd]);
let openssl2: ToolRunner = tl.tool(opensslPath);
openssl2.arg(['x509', '-noout', '-subject']);
openssl1.pipeExecOutputToTool(openssl2);
let commonName: string;
openssl1.on('stdout', function (data) {
if (data) {
// find the subject
data = data.toString().trim();
let subject: string[] = data.match(/subject=.+\/CN=.+\(?.+\)?.+/g);
if (subject && subject[0]) {
// find the CN from the subject
let cn: string[] = subject[0].trim().split('/').filter((s) => {
return s.startsWith('CN=')
});
if (cn && cn[0]) {
commonName = cn[0].replace('CN=', '').trim();
}
}
}
})
await openssl1.exec();
tl.debug('P12 common name (CN) = ' + commonName);
return commonName;
}
示例3: getP12SHA1Hash
export async function getP12SHA1Hash(p12Path: string, p12Pwd: string) {
//openssl pkcs12 -in <p12Path> -nokeys -passin pass:"<p12Pwd>" | openssl x509 -noout –fingerprint
let opensslPath: string = tl.which('openssl', true);
let openssl1: ToolRunner = tl.tool(opensslPath);
openssl1.arg(['pkcs12', '-in', p12Path, '-nokeys', '-passin', 'pass:' + p12Pwd]);
let openssl2: ToolRunner = tl.tool(opensslPath);
openssl2.arg(['x509', '-noout', '-fingerprint']);
openssl1.pipeExecOutputToTool(openssl2);
let sha1Hash: string;
openssl1.on('stdout', function (data) {
if (data) {
// find the fingerprint
data = data.toString().trim();
let fingerprint: string[] = data.match(/SHA1 Fingerprint=.+/g);
if (fingerprint && fingerprint[0]) {
sha1Hash = fingerprint[0].replace('SHA1 Fingerprint=', '').replace(/:/g, '').trim();
}
}
})
await openssl1.exec();
tl.debug('P12 SHA1 hash = ' + sha1Hash);
return sha1Hash;
}
示例4: getP12PrivateKeyName
export async function getP12PrivateKeyName(p12Path: string, p12Pwd: string): Promise<string> {
//openssl pkcs12 -in <p12Path> -nocerts -passin pass:"<p12Pwd>" -passout pass:"<p12Pwd>" | grep 'friendlyName'
tl.debug('getting the P12 private key name');
const opensslPath: string = tl.which('openssl', true);
const openssl: ToolRunner = tl.tool(opensslPath);
if (!p12Pwd) {
// if password is null or not defined, set it to empty
p12Pwd = '';
}
// since we can't suppress the private key bytes, encrypt them before we pass them to grep.
const privateKeyPassword = p12Pwd ? p12Pwd : generatePassword();
openssl.arg(['pkcs12', '-in', p12Path, '-nocerts', '-passin', 'pass:' + p12Pwd, '-passout', 'pass:' + privateKeyPassword]);
//we pipe through grep so we we don't log the private key to the console.
//even if it's encrypted, it's noise and could cause concern for some users.
const grepPath: string = tl.which('grep', true);
const grep: ToolRunner = tl.tool(grepPath);
grep.arg(['friendlyName']);
openssl.pipeExecOutputToTool(grep);
let privateKeyName: string;
openssl.on('stdout', function (data) {
if (data) {
// find the private key name
data = data.toString().trim();
const match = data.match(/friendlyName: (.*)/);
if (match && match[1]) {
privateKeyName = match[1].trim();
}
}
});
await openssl.exec();
tl.debug('P12 private key name = ' + privateKeyName);
if (!privateKeyName) {
throw new Error(tl.loc('P12PrivateKeyNameNotFound', p12Path));
}
return privateKeyName;
}
示例5: getP12SHA1Hash
export async function getP12SHA1Hash(p12Path: string, p12Pwd: string): Promise<string> {
//openssl pkcs12 -in <p12Path> -nokeys -passin pass:"<p12Pwd>" | openssl x509 -noout –fingerprint
let opensslPath: string = tl.which('openssl', true);
let openssl1: ToolRunner = tl.tool(opensslPath);
if (!p12Pwd) {
// if password is null or not defined, set it to empty
p12Pwd = '';
}
openssl1.arg(['pkcs12', '-in', p12Path, '-nokeys', '-passin', 'pass:' + p12Pwd]);
let openssl2: ToolRunner = tl.tool(opensslPath);
openssl2.arg(['x509', '-noout', '-fingerprint']);
openssl1.pipeExecOutputToTool(openssl2);
let sha1Hash: string;
openssl1.on('stdout', function (data) {
if (data) {
// find the fingerprint
data = data.toString().trim();
let fingerprint: string[] = data.match(/SHA1 Fingerprint=.+/g);
if (fingerprint && fingerprint[0]) {
sha1Hash = fingerprint[0].replace('SHA1 Fingerprint=', '').replace(/:/g, '').trim();
}
}
})
try {
await openssl1.exec();
} catch (err) {
if (!p12Pwd) {
tl.warning(tl.loc('NoP12PwdWarning'));
}
throw err;
}
tl.debug('P12 SHA1 hash = ' + sha1Hash);
return sha1Hash;
}
示例6: run
//.........这里部分代码省略.........
//determine the provisioning profile UUID
if(tl.filePathSupplied('provProfile') && tl.exist(provProfilePath)) {
var provProfileUUID = await sign.getProvisioningProfileUUID(provProfilePath);
xcb.argIf(provProfileUUID, 'PROVISIONING_PROFILE=' + provProfileUUID);
if (removeProfile && provProfileUUID) {
profileToDelete = provProfileUUID;
}
}
} else if (signMethod === 'id') {
var unlockDefaultKeychain : boolean = tl.getBoolInput('unlockDefaultKeychain');
var defaultKeychainPassword : string = tl.getInput('defaultKeychainPassword');
if(unlockDefaultKeychain) {
var defaultKeychain : string = await sign.getDefaultKeychainPath();
await sign.unlockKeychain(defaultKeychain, defaultKeychainPassword);
}
var signIdentity : string = tl.getInput('iosSigningIdentity');
xcb.argIf(signIdentity, 'CODE_SIGN_IDENTITY=' + signIdentity);
var provProfileUUID : string = tl.getInput('provProfileUuid');
xcb.argIf(provProfileUUID, 'PROVISIONING_PROFILE=' + provProfileUUID);
}
//--- Enable Xcpretty formatting if using xcodebuild ---
if(useXctool && useXcpretty) {
tl.warning(tl.loc('XcodebuildRequiredForXcpretty'));
}
if(!useXctool && useXcpretty) {
var xcPrettyPath: string = tl.which('xcpretty', true);
var xcPrettyTool: ToolRunner = tl.tool(xcPrettyPath);
xcPrettyTool.arg(['-r', 'junit', '--no-color']);
xcb.pipeExecOutputToTool(xcPrettyTool);
}
//--- Xcode Build ---
await xcb.exec();
//--------------------------------------------------------
// Test publishing
//--------------------------------------------------------
var testResultsFiles : string;
var publishResults : boolean = tl.getBoolInput('publishJUnitResults', false);
if (publishResults)
{
if(useXctool) {
if(xctoolReporter && 0 !== xctoolReporter.length) {
var xctoolReporterString = xctoolReporter.split(":");
if (xctoolReporterString && xctoolReporterString.length === 2) {
testResultsFiles = tl.resolve(workingDir, xctoolReporterString[1].trim());
}
} else {
tl.warning(tl.loc('UseXcToolForTestPublishing'))
}
} else if(!useXctool) {
if(!useXcpretty) {
tl.warning(tl.loc('UseXcprettyForTestPublishing'));
} else {
testResultsFiles = tl.resolve(workingDir, '**/build/reports/junit.xml');
}
}
if(testResultsFiles && 0 !== testResultsFiles.length) {
//check for pattern in testResultsFiles
示例7: run
//.........这里部分代码省略.........
if (unlockDefaultKeychain) {
var defaultKeychain: string = await sign.getDefaultKeychainPath();
await sign.unlockKeychain(defaultKeychain, defaultKeychainPassword);
}
var signIdentity: string = tl.getInput('iosSigningIdentity');
if (signIdentity && !automaticSigningWithXcode) {
xcode_codeSignIdentity = 'CODE_SIGN_IDENTITY=' + signIdentity;
}
var provProfileUUID: string = tl.getInput('provProfileUuid');
if (provProfileUUID && !automaticSigningWithXcode) {
xcode_provProfile = 'PROVISIONING_PROFILE=' + provProfileUUID;
}
}
xcb.argIf(xcode_codeSignIdentity, xcode_codeSignIdentity);
xcb.argIf(xcode_provProfile, xcode_provProfile);
var teamId: string = tl.getInput('teamId');
if (teamId && automaticSigningWithXcode) {
xcode_devTeam = 'DEVELOPMENT_TEAM=' + teamId;
}
xcb.argIf(xcode_devTeam, xcode_devTeam);
//--- Enable Xcpretty formatting if using xcodebuild ---
if (useXctool && useXcpretty) {
tl.warning(tl.loc('XcodebuildRequiredForXcpretty'));
}
if (!useXctool && useXcpretty) {
var xcPrettyPath: string = tl.which('xcpretty', true);
var xcPrettyTool: ToolRunner = tl.tool(xcPrettyPath);
xcPrettyTool.arg(['-r', 'junit', '--no-color']);
xcb.pipeExecOutputToTool(xcPrettyTool);
}
//--- Xcode Build ---
await xcb.exec();
//--------------------------------------------------------
// Test publishing
//--------------------------------------------------------
var testResultsFiles: string;
var publishResults: boolean = tl.getBoolInput('publishJUnitResults', false);
if (publishResults) {
if (useXctool) {
if (xctoolReporter && 0 !== xctoolReporter.length) {
var xctoolReporterString = xctoolReporter.split(":");
if (xctoolReporterString && xctoolReporterString.length === 2) {
testResultsFiles = tl.resolve(workingDir, xctoolReporterString[1].trim());
}
} else {
tl.warning(tl.loc('UseXcToolForTestPublishing'))
}
} else if (!useXctool) {
if (!useXcpretty) {
tl.warning(tl.loc('UseXcprettyForTestPublishing'));
} else {
testResultsFiles = tl.resolve(workingDir, '**/build/reports/junit.xml');
}
}
if (testResultsFiles && 0 !== testResultsFiles.length) {
//check for pattern in testResultsFiles
if (testResultsFiles.indexOf('*') >= 0 || testResultsFiles.indexOf('?') >= 0) {
示例8: run
//.........这里部分代码省略.........
// in the project file, they should choose the "Project Defaults" signing style.
xcode_provProfile = `PROVISIONING_PROFILE=${provProfileUUID}`;
xcode_provProfileSpecifier = `PROVISIONING_PROFILE_SPECIFIER=${provProfileName}`;
}
else if (signingOption === 'auto') {
xcode_codeSignStyle = 'CODE_SIGN_STYLE=Automatic';
let teamId: string = tl.getInput('teamId');
if (teamId) {
xcode_devTeam = 'DEVELOPMENT_TEAM=' + teamId;
}
}
xcb.argIf(xcode_codeSigningAllowed, xcode_codeSigningAllowed);
xcb.argIf(xcode_codeSignStyle, xcode_codeSignStyle);
xcb.argIf(xcode_codeSignIdentity, xcode_codeSignIdentity);
xcb.argIf(xcode_provProfile, xcode_provProfile);
xcb.argIf(xcode_provProfileSpecifier, xcode_provProfileSpecifier);
xcb.argIf(xcode_devTeam, xcode_devTeam);
//--- Enable Xcpretty formatting ---
if (useXcpretty && !tl.which('xcpretty')) {
// user wants to enable xcpretty but it is not installed, fallback to xcodebuild raw output
useXcpretty = false;
tl.warning(tl.loc("XcprettyNotInstalled"));
}
if (useXcpretty) {
let xcPrettyPath: string = tl.which('xcpretty', true);
let xcPrettyTool: ToolRunner = tl.tool(xcPrettyPath);
xcPrettyTool.arg(['-r', 'junit', '--no-color']);
const logFile: string = utils.getUniqueLogFileName('xcodebuild');
xcb.pipeExecOutputToTool(xcPrettyTool, logFile);
utils.setTaskState('XCODEBUILD_LOG', logFile);
}
//--- Xcode Build ---
let buildOnlyDeviceErrorFound: boolean;
xcb.on('errline', (line: string) => {
if (!buildOnlyDeviceErrorFound && line.includes('build only device cannot be used to run this target')) {
buildOnlyDeviceErrorFound = true;
}
});
try {
await xcb.exec();
} catch (err) {
if (buildOnlyDeviceErrorFound) {
// Tell the user they need to change Destination platform to fix this build error.
tl.warning(tl.loc('NoDestinationPlatformWarning'));
}
throw err;
}
//--------------------------------------------------------
// Package app to generate .ipa
//--------------------------------------------------------
if (tl.getBoolInput('packageApp', true) && sdk !== 'iphonesimulator') {
// use xcodebuild to create the app package
if (!scheme) {
throw new Error(tl.loc("SchemeRequiredForArchive"));
}
if (!ws || !tl.filePathSupplied('xcWorkspacePath')) {
throw new Error(tl.loc("WorkspaceOrProjectRequiredForArchive"));
}