本文整理汇总了TypeScript中vsts-task-lib/toolrunner.ToolRunner.line方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolRunner.line方法的具体用法?TypeScript ToolRunner.line怎么用?TypeScript ToolRunner.line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vsts-task-lib/toolrunner.ToolRunner
的用法示例。
在下文中一共展示了ToolRunner.line方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: execute
(async function execute() {
try {
var execOptions: IExecOptions = {
cwd: undefined,
env: undefined,
silent: undefined,
failOnStdErr: undefined,
ignoreReturnCode: undefined,
errStream: undefined,
outStream: undefined,
windowsVerbatimArguments: undefined
};
var toolRunner: ToolRunner;
var isWin32 = os.platform() == "win32";
if (isWin32) {
toolRunner = tl.tool(gitVersionPath);
} else {
toolRunner = tl.tool("mono");
toolRunner.arg(gitVersionPath);
}
toolRunner.arg([
sourcesDirectory,
"/output",
"buildserver",
"/nofetch"
]);
if (updateAssemblyInfo) {
toolRunner.arg("/updateassemblyinfo")
if (updateAssemblyInfoFilename) {
toolRunner.arg(updateAssemblyInfoFilename);
} else {
toolRunner.arg("true");
}
}
if (additionalArguments) {
toolRunner.line(additionalArguments);
}
var result = await toolRunner.exec(execOptions);
if (result) {
tl.setResult(tl.TaskResult.Failed, "An error occured during GitVersion execution")
} else {
tl.setResult(tl.TaskResult.Succeeded, "GitVersion executed successfully")
}
}
catch (err) {
tl.debug(err.stack)
tl.setResult(tl.TaskResult.Failed, err);
}
})();
示例2: isMultiModuleProject
function isMultiModuleProject(wrapperScript: string): boolean {
let gradleBuild: ToolRunner = tl.tool(wrapperScript);
gradleBuild.arg('properties');
gradleBuild.line(tl.getInput('options', false));
let data: string = gradleBuild.execSync().stdout;
if (typeof data !== 'undefined' && data) {
let regex: RegExp = new RegExp('subprojects: .*');
let subProjects: RegExpExecArray = regex.exec(data);
tl.debug('Data: ' + subProjects);
if (typeof subProjects !== 'undefined' && subProjects && subProjects.length > 0) {
tl.debug('Sub Projects info: ' + subProjects.toString());
return (subProjects.join(',').toLowerCase() !== 'subprojects: []');
}
}
return false;
}
示例3: run
async function run() {
try {
tl.setResourcePath(path.join( __dirname, 'task.json'));
//--------------------------------------------------------
// Tooling
//--------------------------------------------------------
tl.setEnvVar('DEVELOPER_DIR', tl.getInput('xcodeDeveloperDir', false));
var useXctool : boolean = tl.getBoolInput('useXctool', false);
var tool : string = useXctool ? tl.which('xctool', true) : tl.which('xcodebuild', true);
tl.debug('Tool selected: '+ tool);
//--------------------------------------------------------
// Paths
//--------------------------------------------------------
var workingDir : string = tl.getPathInput('cwd');
tl.cd(workingDir);
var outPath : string = tl.resolve(workingDir, tl.getInput('outputPattern', true)); //use posix implementation to resolve paths to prevent unit test failures on Windows
tl.mkdirP(outPath);
//--------------------------------------------------------
// Xcode args
//--------------------------------------------------------
var ws : string = tl.getPathInput('xcWorkspacePath', false, false);
if(tl.filePathSupplied('xcWorkspacePath')) {
var workspaceMatches = tl.glob(ws);
tl.debug("Found " + workspaceMatches.length + ' workspaces matching.');
if (workspaceMatches.length > 0) {
ws = workspaceMatches[0];
if (workspaceMatches.length > 1) {
tl.warning(tl.loc('MultipleWorkspacesFound', ws));
}
}
else {
throw tl.loc('WorkspaceDoesNotExist');
}
}
var sdk : string = tl.getInput('sdk', false);
var configuration : string = tl.getInput('configuration', false);
var scheme : string = tl.getInput('scheme', false);
var useXcpretty : boolean = tl.getBoolInput('useXcpretty', false);
var xctoolReporter : string = tl.getInput('xctoolReporter', false);
var actions : string [] = tl.getDelimitedInput('actions', ' ', true);
var packageApp : boolean = tl.getBoolInput('packageApp', true);
var args : string = tl.getInput('args', false);
//--------------------------------------------------------
// Exec Tools
//--------------------------------------------------------
// --- Xcode Version ---
var xcv : ToolRunner = tl.tool(tool);
xcv.arg('-version');
await xcv.exec();
// --- Xcode build arguments ---
var xcb: ToolRunner = tl.tool(tool);
xcb.argIf(sdk, ['-sdk', sdk]);
xcb.argIf(configuration, ['-configuration', configuration]);
if(ws && tl.filePathSupplied('xcWorkspacePath')) {
xcb.arg('-workspace');
xcb.arg(ws);
}
xcb.argIf(scheme, ['-scheme', scheme]);
xcb.argIf(useXctool && xctoolReporter, ['-reporter', 'plain', '-reporter', xctoolReporter]);
xcb.arg(actions);
xcb.arg('DSTROOT=' + path.join(outPath, 'build.dst'));
xcb.arg('OBJROOT=' + path.join(outPath, 'build.obj'));
xcb.arg('SYMROOT=' + path.join(outPath, 'build.sym'));
xcb.arg('SHARED_PRECOMPS_DIR=' + path.join(outPath, 'build.pch'));
if (args) {
xcb.line(args);
}
//--------------------------------------------------------
// iOS signing and provisioning
//--------------------------------------------------------
var signMethod : string = tl.getInput('signMethod', false);
var keychainToDelete : string;
var profileToDelete : string;
if(signMethod === 'file') {
var p12 : string = tl.getPathInput('p12', false, false);
var p12pwd : string = tl.getInput('p12pwd', false);
var provProfilePath : string = tl.getPathInput('provProfile', false);
var removeProfile : boolean = tl.getBoolInput('removeProfile', false);
if(tl.filePathSupplied('p12') && tl.exist(p12)) {
p12 = tl.resolve(workingDir, p12);
var keychain : string = path.join(workingDir, '_xcodetasktmp.keychain');
var keychainPwd : string = '_xcodetask_TmpKeychain_Pwd#1';
//create a temporary keychain and install the p12 into that keychain
await sign.installCertInTemporaryKeychain(keychain, keychainPwd, p12, p12pwd);
xcb.arg('OTHER_CODE_SIGN_FLAGS=--keychain=' + keychain);
keychainToDelete = keychain;
//.........这里部分代码省略.........
示例4: run
async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
//read inputs
let solution: string = tl.getPathInput('solution', true, false);
let platform: string = tl.getInput('platform');
let configuration: string = tl.getInput('configuration');
let msbuildArguments: string = tl.getInput('msbuildArguments');
let clean: boolean = tl.getBoolInput('clean');
let logsolutionEvents: boolean = tl.getBoolInput('logsolutionEvents');
if (logsolutionEvents) {
tl.warning(tl.loc('RecordProjectDetailsOnlySupportedOnWindows'));
}
let createLogFile: boolean = tl.getBoolInput('createLogFile');
if (createLogFile) {
tl.warning(tl.loc('CreateLogFileOnlySupportedOnWindows'));
}
let msbuildLocationMethod: string = tl.getInput('msbuildLocationMethod');
if (!msbuildLocationMethod) {
msbuildLocationMethod = 'version';
}
let msbuildTool: string;
if (msbuildLocationMethod === 'version') {
let msbuildVersion: string = tl.getInput('msbuildVersion');
msbuildTool = await msbuildHelpers.getMSBuildPath(msbuildVersion);
}
if (msbuildLocationMethod === 'location') {
msbuildTool = tl.getInput('msbuildLocation');
}
let filesList: string[] = tl.findMatch(null, solution, { followSymbolicLinks: false, followSpecifiedSymbolicLink: false }, { matchBase: true });
for (let file of filesList) {
if (clean) {
let cleanTool: ToolRunner = tl.tool(msbuildTool);
cleanTool.arg(file);
cleanTool.argIf(clean, '/t:Clean');
cleanTool.argIf(platform, '/p:Platform=' + platform);
cleanTool.argIf(configuration, '/p:Configuration=' + configuration);
if (msbuildArguments) {
cleanTool.line(msbuildArguments);
}
await cleanTool.exec();
}
let buildTool: ToolRunner = tl.tool(msbuildTool);
buildTool.arg(file);
buildTool.argIf(platform, '/p:Platform=' + platform);
buildTool.argIf(configuration, '/p:Configuration=' + configuration);
if (msbuildArguments) {
buildTool.line(msbuildArguments);
}
await buildTool.exec();
}
} catch (err) {
tl.setResult(tl.TaskResult.Failed, err);
}
}
示例5: run
//.........这里部分代码省略.........
// Find location of nuget
let nugetPath: string = tl.which('nuget', true);
// Restore NuGet packages of the solution
let nugetRunner: ToolRunner = tl.tool(nugetPath);
nugetRunner.arg(['restore', solutionPath]);
await nugetRunner.exec();
}
//Process working directory
let workingDir: string = cwd || tl.getVariable('System.DefaultWorkingDirectory');
tl.cd(workingDir);
let signMethod: string = tl.getInput('signMethod', false);
let provProfileUUID: string = null;
let signIdentity: string = null;
if (signMethod === 'file') {
let p12: string = tl.getPathInput('p12', false, false);
let p12pwd: string = tl.getInput('p12pwd', false);
let provProfilePath: string = tl.getPathInput('provProfile', false);
let removeProfile: boolean = tl.getBoolInput('removeProfile', false);
if (tl.filePathSupplied('p12') && tl.exist(p12)) {
p12 = tl.resolve(cwd, p12);
tl.debug('cwd = ' + cwd);
let keychain: string = tl.resolve(cwd, '_xamariniostasktmp.keychain');
let keychainPwd: string = '_xamariniostask_TmpKeychain_Pwd#1';
//create a temporary keychain and install the p12 into that keychain
tl.debug('installing cert in temp keychain');
await sign.installCertInTemporaryKeychain(keychain, keychainPwd, p12, p12pwd, false);
codesignKeychain = keychain;
//find signing identity
signIdentity = await sign.findSigningIdentity(keychain);
}
//determine the provisioning profile UUID
if (tl.filePathSupplied('provProfile') && tl.exist(provProfilePath)) {
provProfileUUID = await sign.getProvisioningProfileUUID(provProfilePath);
if (removeProfile && provProfileUUID) {
profileToDelete = provProfileUUID;
}
}
} else if (signMethod === 'id') {
let unlockDefaultKeychain: boolean = tl.getBoolInput('unlockDefaultKeychain');
let defaultKeychainPassword: string = tl.getInput('defaultKeychainPassword');
if (unlockDefaultKeychain) {
let defaultKeychain: string = await sign.getDefaultKeychainPath();
await sign.unlockKeychain(defaultKeychain, defaultKeychainPassword);
}
signIdentity = tl.getInput('iosSigningIdentity');
provProfileUUID = tl.getInput('provProfileUuid');
}
// Prepare xbuild build command line
let buildRunner: ToolRunner = tl.tool(buildToolPath);
buildRunner.arg(solutionPath);
buildRunner.argIf(configuration, '/p:Configuration=' + configuration);
buildRunner.argIf(device, '/p:Platform=' + device);
buildRunner.argIf(packageApp, '/p:BuildIpa=true');
if (args) {
buildRunner.line(args);
}
buildRunner.argIf(codesignKeychain, '/p:CodesignKeychain=' + codesignKeychain);
buildRunner.argIf(signIdentity, '/p:Codesignkey=' + signIdentity);
buildRunner.argIf(provProfileUUID, '/p:CodesignProvision=' + provProfileUUID);
// Execute build
await buildRunner.exec();
tl.setResult(tl.TaskResult.Succeeded, tl.loc('XamariniOSSucceeded'));
} catch (err) {
tl.setResult(tl.TaskResult.Failed, tl.loc('XamariniOSFailed', err));
} finally {
//clean up the temporary keychain, so it is not used to search for code signing identity in future builds
if (codesignKeychain) {
try {
await sign.deleteKeychain(codesignKeychain);
} catch (err) {
tl.debug('Failed to delete temporary keychain. Error = ' + err);
tl.warning(tl.loc('TempKeychainDeleteFailed', codesignKeychain));
}
}
//delete provisioning profile if specified
if (profileToDelete) {
try {
await sign.deleteProvisioningProfile(profileToDelete);
} catch (err) {
tl.debug('Failed to delete provisioning profile. Error = ' + err);
tl.warning(tl.loc('ProvProfileDeleteFailed', profileToDelete));
}
}
}
}
示例6: run
async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
//read inputs
const project: string | null = tl.getPathInput('project', true);
const target: string | null = tl.getInput('target');
const outputDir: string | null = tl.getInput('outputDir');
const configuration: string | null = tl.getInput('configuration');
const createAppPackage: boolean | null = tl.getBoolInput('createAppPackage');
const clean: boolean | null = tl.getBoolInput('clean');
const msbuildArguments: string| null = tl.getInput('msbuildArguments');
// find jdk to be used during the build
const jdkSelection: string = tl.getInput('jdkSelection') || 'JDKVersion'; // fall back to JDKVersion for older version of tasks
let specifiedJavaHome: string | null | undefined = null;
let javaTelemetryData: { jdkVersion: string } | null = null;
if (jdkSelection === 'JDKVersion') {
tl.debug('Using JDK version to find JDK path');
const jdkVersion: string | null = tl.getInput('jdkVersion');
const jdkArchitecture: string | null = tl.getInput('jdkArchitecture');
javaTelemetryData = { jdkVersion };
if (jdkVersion !== 'default') {
specifiedJavaHome = javacommons.findJavaHome(jdkVersion, jdkArchitecture);
}
} else {
tl.debug('Using path from user input to find JDK');
specifiedJavaHome = tl.getPathInput('jdkUserInputPath', true, true);
javaTelemetryData = { jdkVersion: "custom" };
}
javacommons.publishJavaTelemetry('XamarinAndroid', javaTelemetryData);
//find build tool path to use
let buildToolPath: string | undefined;
const buildLocationMethod: string = tl.getInput('msbuildLocationMethod') || 'version';
const buildToolLocation: string | null = tl.getPathInput('msbuildLocation');
if (buildToolLocation) {
// msbuildLocation was specified, use it for back compat
if (buildToolLocation.endsWith('xbuild') || buildToolLocation.endsWith('msbuild')) {
buildToolPath = buildToolLocation;
} else {
// use xbuild for back compat if tool folder path is specified
buildToolPath = path.join(buildToolLocation, 'xbuild');
}
tl.checkPath(buildToolPath, 'build tool');
} else if (buildLocationMethod === 'version') {
// msbuildLocation was not specified, look up by version
const msbuildVersion: string = tl.getInput('msbuildVersion');
buildToolPath = await msbuildHelpers.getMSBuildPath(msbuildVersion);
}
if (!buildToolPath) {
throw tl.loc('MSB_BuildToolNotFound');
}
tl.debug('Build tool path = ' + buildToolPath);
// Resolve files for the specified value or pattern
const filesList: string[] = tl.findMatch('', project, { followSymbolicLinks: false, followSpecifiedSymbolicLink: false });
// Fail if no matching .csproj files were found
if (!filesList || filesList.length === 0) {
throw tl.loc('NoMatchingProjects', project);
}
for (const file of filesList) {
try {
// run the build for each matching project
const buildRunner: ToolRunner = tl.tool(buildToolPath);
buildRunner.arg(file);
buildRunner.argIf(clean, '/t:Clean');
buildRunner.argIf(target, '/t:' + target);
buildRunner.argIf(createAppPackage, '/t:PackageForAndroid');
if (msbuildArguments) {
buildRunner.line(msbuildArguments);
}
buildRunner.argIf(outputDir, '/p:OutputPath=' + outputDir);
buildRunner.argIf(configuration, '/p:Configuration=' + configuration);
buildRunner.argIf(specifiedJavaHome, '/p:JavaSdkDirectory=' + specifiedJavaHome);
await buildRunner.exec();
} catch (err) {
throw tl.loc('XamarinAndroidBuildFailed', err);
}
tl.setResult(tl.TaskResult.Succeeded, tl.loc('XamarinAndroidSucceeded'));
}
} catch (err) {
tl.setResult(tl.TaskResult.Failed, err);
}
}
示例7: run
//.........这里部分代码省略.........
if (match) {
var version: number = parseInt(match.toString().replace('Xcode', '').trim());
tl.debug('version = ' + version);
if (!isNaN(version)) {
xcodeVersion = version;
}
}
});
await xcv.exec();
tl.debug('xcodeVersion = ' + xcodeVersion);
// --- Xcode build arguments ---
var xcb: ToolRunner = tl.tool(tool);
xcb.argIf(sdk, ['-sdk', sdk]);
xcb.argIf(configuration, ['-configuration', configuration]);
if (ws && tl.filePathSupplied('xcWorkspacePath')) {
xcb.argIf(isProject, '-project');
xcb.argIf(!isProject, '-workspace');
xcb.arg(ws);
}
xcb.argIf(scheme, ['-scheme', scheme]);
xcb.argIf(useXctool && xctoolReporter, ['-reporter', 'plain', '-reporter', xctoolReporter]);
xcb.arg(actions);
if (actions.toString().indexOf('archive') < 0) {
// redirect build output if archive action is not passed
// xcodebuild archive produces an invalid archive if output is redirected
xcb.arg('DSTROOT=' + tl.resolve(outPath, 'build.dst'));
xcb.arg('OBJROOT=' + tl.resolve(outPath, 'build.obj'));
xcb.arg('SYMROOT=' + tl.resolve(outPath, 'build.sym'));
xcb.arg('SHARED_PRECOMPS_DIR=' + tl.resolve(outPath, 'build.pch'));
}
if (args) {
xcb.line(args);
}
//--------------------------------------------------------
// iOS signing and provisioning
//--------------------------------------------------------
var signMethod: string = tl.getInput('signMethod', false);
var keychainToDelete: string;
var profileToDelete: string;
var automaticSigningWithXcode: boolean = tl.getBoolInput('xcode8AutomaticSigning');
var xcode_otherCodeSignFlags: string;
var xcode_codeSignIdentity: string;
var xcode_provProfile: string;
var xcode_devTeam: string;
if (signMethod === 'file') {
var p12: string = tl.getPathInput('p12', false, false);
var p12pwd: string = tl.getInput('p12pwd', false);
var provProfilePath: string = tl.getPathInput('provProfile', false);
var removeProfile: boolean = tl.getBoolInput('removeProfile', false);
if (tl.filePathSupplied('p12') && tl.exist(p12)) {
p12 = tl.resolve(workingDir, p12);
var keychain: string = tl.resolve(workingDir, '_xcodetasktmp.keychain');
var keychainPwd: string = '_xcodetask_TmpKeychain_Pwd#1';
//create a temporary keychain and install the p12 into that keychain
await sign.installCertInTemporaryKeychain(keychain, keychainPwd, p12, p12pwd, false);
xcode_otherCodeSignFlags = 'OTHER_CODE_SIGN_FLAGS=--keychain=' + keychain;
xcb.arg(xcode_otherCodeSignFlags);
keychainToDelete = keychain;
utils.setTaskState('XCODE_KEYCHAIN_TO_DELETE', keychainToDelete);
示例8: execute
(async function execute(): Promise<void> {
try {
const azCopy: string[] = azCopyknownLocations.filter((x) => fs.existsSync(x));
if (azCopy.length) {
tl.debug("AzCopy utility found at path : " + azCopy[0]);
const toolRunner: ToolRunner = tl.tool(azCopy[0]);
if (sourceKind === "Storage") {
tl.debug("retrieving source account details");
const sourceCredentials: any = await getConnectedServiceCredentials(sourceConnectedServiceName);
const sourceStorageAccount: IStorageAccount = await getStorageAccount(sourceCredentials, sourceAccount);
tl.debug(sourceStorageAccount.blobEndpoint + sourceObject);
toolRunner.arg("/Source:" + sourceStorageAccount.blobEndpoint + sourceObject);
toolRunner.arg("/SourceKey:" + sourceStorageAccount.key);
} else {
toolRunner.arg("/Source:" + sourcePath);
}
if (destinationKind === "Storage") {
const destCredentials: any = await getConnectedServiceCredentials(destinationConnectedServiceName);
const destStorageAccount: IStorageAccount = await getStorageAccount(
destCredentials,
destinationAccount);
tl.debug(destStorageAccount.blobEndpoint + destinationObject);
toolRunner.arg("/Dest:" + destStorageAccount.blobEndpoint + destinationObject);
toolRunner.arg("/DestKey:" + destStorageAccount.key);
} else {
toolRunner.arg("/Dest:" + destinationPath);
}
if (recursive) {
toolRunner.arg("/S");
}
if (pattern) {
toolRunner.arg("/Pattern:" + pattern);
}
if (excludeNewer) {
toolRunner.arg("/XN");
}
if (excludeOlder) {
toolRunner.arg("/XO");
}
if (additionalArguments) {
toolRunner.line(additionalArguments);
}
toolRunner.arg("/Y");
const result: number = await toolRunner.exec();
if (result) {
tl.setResult(tl.TaskResult.Failed, "An error occured during azcopy");
} else {
tl.setResult(tl.TaskResult.Succeeded, "Files copied successfully");
}
} else {
tl.setResult(
tl.TaskResult.Failed,
"AzCopy utility was not found, please refer to documentation for installation instructions.");
}
} catch (err) {
tl.debug(err.stack);
tl.setResult(tl.TaskResult.Failed, err);
}
})();
示例9: run
//.........这里部分代码省略.........
xcv.on('stdout', (data) => {
let match = data.toString().trim().match(/Xcode (.+)/g);
tl.debug('match = ' + match);
if (match) {
let version: number = parseInt(match.toString().replace('Xcode', '').trim());
tl.debug('version = ' + version);
if (!isNaN(version)) {
xcodeVersion = version;
}
}
});
await xcv.exec();
tl.debug('xcodeVersion = ' + xcodeVersion);
// --- Xcode build arguments ---
let xcb: ToolRunner = tl.tool(tool);
xcb.argIf(sdk, ['-sdk', sdk]);
xcb.argIf(configuration, ['-configuration', configuration]);
if (ws && tl.filePathSupplied('xcWorkspacePath')) {
xcb.argIf(isProject, '-project');
xcb.argIf(!isProject, '-workspace');
xcb.arg(ws);
}
xcb.argIf(scheme, ['-scheme', scheme]);
// Add a -destination argument for each device and simulator.
if (destinations) {
destinations.forEach(destination => {
xcb.arg(['-destination', destination]);
});
}
xcb.arg(actions);
if (args) {
xcb.line(args);
}
//--------------------------------------------------------
// iOS signing and provisioning
//--------------------------------------------------------
let signingOption: string = tl.getInput('signingOption', true);
let keychainToDelete: string;
let profileToDelete: string;
let xcode_codeSigningAllowed: string;
let xcode_codeSignStyle: string;
let xcode_otherCodeSignFlags: string;
let xcode_codeSignIdentity: string;
let xcode_provProfile: string;
let xcode_provProfileSpecifier: string;
let xcode_devTeam: string;
if (signingOption === 'nosign') {
xcode_codeSigningAllowed = 'CODE_SIGNING_ALLOWED=NO';
}
else if (signingOption === 'manual') {
xcode_codeSignStyle = 'CODE_SIGN_STYLE=Manual';
const signIdentity: string = tl.getInput('signingIdentity');
if (signIdentity) {
xcode_codeSignIdentity = 'CODE_SIGN_IDENTITY=' + signIdentity;
}
let provProfileUUID: string = tl.getInput('provisioningProfileUuid');
let provProfileName: string = tl.getInput('provisioningProfileName');
if (!provProfileUUID) {
provProfileUUID = "";
示例10: run
async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
// Configure wrapperScript
let wrapperScript: string = tl.getPathInput('wrapperScript', true, true);
wrapperScript = configureWrapperScript(wrapperScript);
// Set working directory
let workingDirectory: string = tl.getPathInput('cwd', false, true);
if (!workingDirectory) {
workingDirectory = path.dirname(wrapperScript);
}
tl.cd(workingDirectory);
let javaHomeSelection: string = tl.getInput('javaHomeSelection', true);
let codeCoverageTool: string = tl.getInput('codeCoverageTool');
let isCodeCoverageOpted: boolean = (typeof codeCoverageTool !== 'undefined' && codeCoverageTool && codeCoverageTool.toLowerCase() !== 'none');
let publishJUnitResults: boolean = tl.getBoolInput('publishJUnitResults');
let testResultsFiles: string = tl.getInput('testResultsFiles', true);
let inputTasks: string[] = tl.getDelimitedInput('tasks', ' ', true);
let buildOutput: BuildOutput = new BuildOutput(tl.getVariable('System.DefaultWorkingDirectory'), BuildEngine.Gradle);
//START: Get gradleRunner ready to run
let gradleRunner: ToolRunner = tl.tool(wrapperScript);
if (isCodeCoverageOpted && inputTasks.indexOf('clean') === -1) {
gradleRunner.arg('clean'); //if user opts for code coverage, we append clean functionality to make sure any uninstrumented class files are removed
}
gradleRunner.line(tl.getInput('options', false));
gradleRunner.arg(inputTasks);
//END: Get gb ready to run
// Set JAVA_HOME based on any user input
setJavaHome(javaHomeSelection);
// Set any provided gradle options
let gradleOptions: string = tl.getInput('gradleOpts');
setGradleOpts(gradleOptions);
// START: Enable code coverage (if desired)
let reportDirectoryName: string = 'CCReport43F6D5EF';
let reportDirectory: string = path.join(workingDirectory, reportDirectoryName);
let summaryFile: string = null;
let reportingTaskName: string = '';
try {
if (isCodeCoverageOpted) {
tl.debug('Option to enable code coverage was selected and is being applied.');
let classFilter: string = tl.getInput('classFilter');
let classFilesDirectories: string = tl.getInput('classFilesDirectories');
// START: determine isMultiModule
let isMultiModule: boolean = isMultiModuleProject(wrapperScript);
let summaryFileName: string;
if (codeCoverageTool.toLowerCase() === 'jacoco') {
summaryFileName = 'summary.xml';
if (isMultiModule) {
reportingTaskName = 'jacocoRootReport';
} else {
reportingTaskName = 'jacocoTestReport';
}
} else if (codeCoverageTool.toLowerCase() === 'cobertura') {
summaryFileName = 'coverage.xml';
reportingTaskName = 'cobertura';
}
summaryFile = path.join(reportDirectory, summaryFileName);
// END: determine isMultiModule
// Clean the report directory before enabling code coverage
tl.rmRF(reportDirectory, true);
await enableCodeCoverage(wrapperScript, isCodeCoverageOpted,
classFilter, classFilesDirectories,
codeCoverageTool, workingDirectory, reportDirectoryName,
summaryFileName, isMultiModule);
}
tl.debug('Enabled code coverage successfully');
} catch (err) {
tl.warning('Failed to enable code coverage: ' + err);
}
if (reportingTaskName && reportingTaskName !== '') {
gradleRunner.arg(reportingTaskName);
}
// END: Enable code coverage (if desired)
let codeAnalysisOrchestrator: CodeAnalysisOrchestrator = new CodeAnalysisOrchestrator(
[new CheckstyleTool(buildOutput, 'checkstyleAnalysisEnabled'),
new FindbugsTool(buildOutput, 'findbugsAnalysisEnabled'),
new PmdTool(buildOutput, 'pmdAnalysisEnabled')]);
// Enable SonarQube Analysis (if desired)
let isSonarQubeEnabled: boolean = sqCommon.isSonarQubeAnalysisEnabled();
if (isSonarQubeEnabled) {
// Looks like: 'SonarQube analysis is enabled.'
console.log(tl.loc('codeAnalysis_ToolIsEnabled'), sqCommon.toolName);
gradleRunner = sqGradle.applyEnabledSonarQubeArguments(gradleRunner);
gradleRunner = sqGradle.applySonarQubeCodeCoverageArguments(gradleRunner, isCodeCoverageOpted, codeCoverageTool, summaryFile);
}
gradleRunner = codeAnalysisOrchestrator.configureBuild(gradleRunner);
// START: Run code analysis
//.........这里部分代码省略.........