當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ToolRunner.pipeExecOutputToTool方法代碼示例

本文整理匯總了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;
}
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:29,代碼來源:ios-signing-common.ts

示例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;
}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:35,代碼來源:ios-signing-common.ts

示例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;
}
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:25,代碼來源:ios-signing-common.ts

示例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;
}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:41,代碼來源:ios-signing-common.ts

示例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;
}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:38,代碼來源:ios-signing-common.ts

示例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
開發者ID:HSAR,項目名稱:vso-agent-tasks,代碼行數:67,代碼來源:xcode.ts

示例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) {
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:67,代碼來源:xcode.ts

示例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"));
            }
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:67,代碼來源:xcode.ts


注:本文中的vsts-task-lib/toolrunner.ToolRunner.pipeExecOutputToTool方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。