@groovy.util.logging.Slf4j class ObiPlugin extends java.lang.Object
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
apply(org.gradle.api.Project project) |
|
void |
applyExtension(org.gradle.api.Project project)' include 'com/redpillanalytics/obi/catalog/**' } } catch (Throwable e) { // apparently, I only need to catch it // the task still configures // the job creation must succeed, but the configuration must fail } |
|
java.lang.Object |
buildRelativePath(org.gradle.api.Project project, java.io.File full) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
' include 'com/redpillanalytics/obi/catalog/**' } } catch (Throwable e) { // apparently, I only need to catch it // the task still configures // the job creation must succeed, but the configuration must fail } project.task('baselineTest') { group "$GROUP_PREFIX Testing" description 'Execute all Baseline regression tests for the entire project.' } project.task('revisionTest') { group "$GROUP_PREFIX Testing" description 'Execute all Revision regression tests for the entire project.' } // create the holding tasks to run all compare tasks project.task('compareTest') { group "$GROUP_PREFIX Testing" description 'Execute all Compare regression tests for the entire project.' mustRunAfter project.tasks.revisionTest } // Default test group // these are added before the closure so they are executed first project.extensions.obi.testGroups.add(new TestGroupContainer(DEFAULT_TEST_GROUP)) //todo Begin Test Group Closure project.extensions.obi.testGroups.configureEach { tg -> String testUser = tg.testUser ?: getParameter('testUser') ?: adminUser String testPassword = tg.testPassword ?: getParameter('testPassword') ?: adminPassword String libraryFolder = getParameter('libraryFolder') ?: tg.libraryFolder ?: '/shared/regression' log.debug "Configuring ${tg.getName()} testGroup" log.debug "library Folder: ${tg.getLibraryFolder()}" log.debug "test directories: ${tg.getBaselineName()}, ${tg.getRevisionName()}" // directories specific to RegressionTestTask File baselineResultsDir = project.file("$project.buildDir/${tg.getBaselineName()}") File revisionResultsDir = project.file("$project.buildDir/${tg.getRevisionName()}") File compareResultsDir = project.file("$project.buildDir/${tg.getCompareName()}") // files for baseline and regression libraries File baselineLibrary = project.file("$project.buildDir/${tg.getBaselineLibraryPath()}") File revisionLibrary = project.file("$project.buildDir/${tg.getRevisionLibraryPath()}") File compareLibrary = project.file("$project.buildDir/${tg.getCompareLibraryPath()}") project.task(tg.getTaskName('baselineLibrary'), type: CatalogReportTask) { group tg.getTaskGroup('testing') description = "Create the Baseline regression test library CSV file for Test Group '${tg.name}'." folder libraryFolder outputFile baselineLibrary failPath failOnMissingPath product obiProduct fields 'Name:Path:SQL' } project.task(tg.getTaskName('baselineTest'), type: RegressionTestTask) { group tg.getTaskGroup('testing') description = "Execute the Baseline regression test library file for Test Group '${tg.name}'." // what to execute include '*BaselineTest*' classpath = project.getBuildscript().getConfigurations().classpath // directories specific to RegressionTestTask baselineDir baselineResultsDir // All other parameters are specific to Test Class // performance minHeapSize tg.getMinHeapSize() maxHeapSize tg.getMaxHeapSize() maxParallelForks tg.getMaxParallelForks() forkEvery tg.getForkEvery() // report destinations reports.junitXml.destination project.file("$project.buildDir/${tg.getBaselineXmlPath()}") reports.html.destination project.file("$project.buildDir/${tg.getBaselineHtmlPath()}") // miscellaneous testClassesDirs = testClasses binResultsDir project.file("$project.buildDir/${tg.getBinResultsName()}") ignoreFailures true scanForTestClasses tg.getScanForTestClasses() testLogging.showStandardStreams tg.showOutput // systemProperties based on Checkmate extension // easy to call that way systemProperty 'resultExt', tg.resultExt systemProperty 'testUser', testUser systemProperty 'testPassword', testPassword systemProperty 'dsnName', dsnName systemProperty 'baselinePath', baselineResultsDir.canonicalPath systemProperty 'libraryName', tg.libraryName systemProperty 'tempDir', temporaryDir systemProperty 'sourceQueryDelimiter', tg.sourceQueryDelimiter systemProperty 'replaceQueryDelimiter', tg.replaceQueryDelimiter systemProperty 'biServerExec', obiProduct.getCommand('nqcmd') systemProperty 'impersonateUser', tg.impersonateUser systemProperty 'queryLog', tg.queryLog ? 'true' : 'false' // dependencies dependsOn tg.getTaskName('baselineLibrary') mustRunAfter tg.getTaskName('baselineLibrary') // only run if the library file exists onlyIf { project.file("${baselineResultsDir}/${tg.libraryName}").exists() } } project.tasks.baselineTest.dependsOn tg.getTaskName('baselineTest') project.task(tg.getTaskName('revisionLibrary'), type: CatalogReportTask) { group tg.getTaskGroup('testing') description = "Create the Revision regression test library CSV file for Test Group '${tg.name}'." folder libraryFolder outputFile revisionLibrary failPath failOnMissingPath product obiProduct fields 'Name:Path:SQL' } project.task(tg.getTaskName('revisionTest'), type: RegressionTestTask) { group tg.getTaskGroup('testing') description = "Execute the Revision regression test library file for Test Group '${tg.name}'." // what to execute include '*RevisionTest*' classpath = project.getBuildscript().getConfigurations().classpath // directories specific to RegressionTestTask revisionDir revisionResultsDir // All other parameters are specific to Test Class // performance minHeapSize tg.getMinHeapSize() maxHeapSize tg.getMaxHeapSize() maxParallelForks tg.getMaxParallelForks() forkEvery tg.getForkEvery() // report destinations reports.junitXml.destination project.file("$project.buildDir/${tg.getRevisionXmlPath()}") reports.html.destination project.file("$project.buildDir/${tg.getRevisionHtmlPath()}") // miscellaneous testClassesDirs = testClasses binResultsDir project.file("$project.buildDir/${tg.getBinResultsName()}") ignoreFailures true scanForTestClasses tg.getScanForTestClasses() testLogging.showStandardStreams tg.showOutput // systemProperties based on Checkmate extension // easy to call that way systemProperty 'resultExt', tg.resultExt systemProperty 'testUser', testUser systemProperty 'testPassword', testPassword systemProperty 'dsnName', dsnName systemProperty 'revisionPath', revisionResultsDir.canonicalPath systemProperty 'libraryName', tg.libraryName systemProperty 'tempDir', temporaryDir systemProperty 'sourceQueryDelimiter', tg.sourceQueryDelimiter systemProperty 'replaceQueryDelimiter', tg.replaceQueryDelimiter systemProperty 'biServerExec', obiProduct.getCommand('nqcmd') systemProperty 'impersonateUser', tg.impersonateUser systemProperty 'queryLog', tg.queryLog ? 'true' : 'false' // dependencies dependsOn tg.getTaskName('revisionLibrary') mustRunAfter tg.getTaskName('revisionLibrary') // only run if the library file exists onlyIf { project.file("${revisionResultsDir}/${tg.libraryName}").exists() } } project.tasks.revisionTest.dependsOn tg.getTaskName('revisionTest') project.task(tg.getTaskName('compareTest'), type: RegressionTestTask) { group tg.getTaskGroup('testing') description "Compare the differences between the Baseline and Revision regression test results for Test Group '${tg.name}'." // only execute if we have the other two onlyIf { baselineLibrary || revisionLibrary } // what to execute include '*CompareTest*' classpath = project.getBuildscript().getConfigurations().classpath // directories specific to RegressionTestTask baselineDir baselineResultsDir revisionDir revisionResultsDir compareDir compareResultsDir // All other parameters are specific to Test Class // performance minHeapSize tg.getMinHeapSize() maxHeapSize tg.getMaxHeapSize() maxParallelForks tg.getMaxParallelForks() forkEvery tg.getForkEvery() // report destinations reports.junitXml.destination project.file("$project.buildDir/${tg.getCompareXmlPath()}") reports.html.destination project.file("$project.buildDir/${tg.getCompareHtmlPath()}") // miscellaneous testClassesDirs = testClasses binResultsDir project.file("$project.buildDir/${tg.getBinResultsName()}") ignoreFailures true scanForTestClasses tg.getScanForTestClasses() testLogging.showStandardStreams tg.showOutput // dependencies mustRunAfter tg.getTaskName('revisionTest') // system properties systemProperty 'baselinePath', baselineResultsDir.canonicalPath systemProperty 'revisionPath', revisionResultsDir.canonicalPath systemProperty 'comparePath', compareResultsDir.canonicalPath systemProperty 'libraryName', tg.libraryName systemProperty 'compareLogical', tg.compareLogical.toString() systemProperty 'compareHash', tg.compareHash.toString() systemProperty 'compareText', tg.compareText.toString() // only run if the library files exists onlyIf { project.file("${revisionResultsDir}/${tg.libraryName}").exists() } onlyIf { project.file("${baselineResultsDir}/${tg.libraryName}").exists() } } //OBI Test Analytics if (project.rootProject.plugins.findPlugin('com.redpillanalytics.gradle-analytics')) { // add an afterSuite listener to handle the compare files project.tasks.findByName(tg.getTaskName('compareTest')).afterSuite { desc, result -> log.debug "desc: ${desc.dump()}" // We only want to write to the file one time, so we do this for the outermost suite if (!desc.parent) { compareLibrary.eachLine { String line, Integer count -> line.find(/([^\|]+)(\|)([^\|]+)(\|)([^\|]+)(\|)([^\|]+)(\|)?([^\|]+)?(\|)?([^\|]+)?/) { all, name, pipe1, path, pipe2, blSql, pipe3, rlSql, pipe4, bHash, pipe5, rHash -> // first line is a header row if (count != 1) { // write tests to the analytics file project.rootProject.extensions.analytics.writeAnalytics( project.extensions.obi.testFileName as String, project.rootProject.buildDir, // easy way of adding Maps together in Groovy // basically add build metadata plus custom fields together project.rootProject.extensions.analytics.getBuildHeader() << [ projectname : project.displayName, projectdir : project.projectDir.path, builddir : project.buildDir.path, buildfile : project.buildFile.path, compatibility : obiProduct.compatibility, domainhome : obiProduct.domainHome, serviceinstance: obiProduct.serviceInstance, testgroup : tg.name, libraryfolder : tg.getLibraryFolder(), analysisname : name, analysispath : path, baselinelsql : blSql, baselinehash : bHash, revisionlsql : rlSql, revisionhash : rHash, // adjust for missing header record linenumber : count - 1 ] ) } } } } } } project.tasks.compareTest.dependsOn tg.getTaskName('compareTest') } Boolean enableBuildGroups = getParameter('enableBuildGroups').toBoolean() log.debug "enableBuildGroups: $enableBuildGroups" // create the default feature and release BuildGroupContainer contexts if "enableBuildGroups" if (enableBuildGroups) { // pre-seed with the default Context build tasks project.extensions.obi.buildGroups.add(new BuildGroupContainer('feature')) project.extensions.obi.buildGroups.add(new BuildGroupContainer('release')) project.extensions.obi.buildGroups.add(new BuildGroupContainer('promote')) } // create the CURRENT_BUILD_NAME (non-context) workflows project.extensions.obi.buildGroups.add(new BuildGroupContainer(CURRENT_BUILD_NAME)) //todo Begin Build Group All Closure project.extensions.obi.buildGroups.configureEach { bga -> String repositoryPassword = getParameter("${bga.name}Password") ?: getParameter('repositoryPassword') // Build Export Lifecycle task if (bga.isCurrentTask()) { // Exporting connection pools are always are part of the process project.task(bga.getTaskName('connPoolsExport'), type: ConnPoolsExportTask) { group bga.getTaskGroup('export') description "Export target OBIEE server connection pool information in JSON format to '${buildRelativePath(project, connPoolsFile)}'." conn connPoolsFile variables exportConnPoolVars password repositoryPassword product obiProduct outputs.upToDateWhen { false } rest = useRestApi } // Exporting variables are always a part project.task(bga.getTaskName('variablesExport'), type: VariablesExportTask) { group bga.getTaskGroup('export') description "Export target OBIEE server variable information in JSON format to '${buildRelativePath(project, variablesFile)}'." outputFile variablesFile product obiProduct rest = useRestApi outputs.upToDateWhen { false } } //todo Configure catalog privs export // project.task(bga.getTaskName('catalogPrivsExport'), type: CatalogReportTask) { // // group bga.getTaskGroup('export') // description = "Export presentation catalog permissions to '${buildRelativePath(project, variablesFile)}'." // // folder libraryFolder // filePath revisionLibrary.absolutePath // failPath failOnMissingPath // product obiProduct // } // // catalog permissions // project.task(bga.getTaskName('catalogPrivsExport')) { // // group bga.getTaskGroup('export') // description = "Export presentation catalog permissions to '${buildRelativePath(project, variablesFile)}'." // // folder libraryFolder // report revisionLibrary // failPath failOnMissingPath // product obiProduct // } // Export Task project.task(bga.getTaskName('export')) { group bga.getTaskGroup('export') description = "Execute all configured export tasks${bga.getForContext()}." //dependsOn bga.getTaskName('connPoolsExport'), bga.getTaskName('variablesExport') } } // Build the lifecycle Import task // We have imports for all build tasks as well as tasks associated with usable configurations if (bga.isCurrentTask() || isUsableConfiguration(bga.name)) { project.task(bga.getTaskName('import')) { group bga.getTaskGroup('import') description = "Execute all configured import tasks${bga.getForContext()}." } } // Patch lifecycle task if (isUsableConfiguration(bga.name)) { // Patch Task taskName = bga.getTaskName('patch') groupName = bga.getTaskGroup('patch') project.task(taskName) { group groupName description = "Execute all configured patch tasks${bga.getForContext()}." } // Unpatch Task taskName = bga.getTaskName('unpatch') groupName = bga.getTaskGroup('patch') project.task(taskName) { group groupName description = "Execute all configured unpatch tasks${bga.getForContext()}." } } if (bga.isNonConfigTask()) { // Conn Pool Import Task taskName = bga.getTaskName('connPoolsImport') groupName = bga.getTaskGroup('import') project.task(taskName, type: ConnPoolsImportTask) { group groupName description "Import server connection pool information in JSON format from '${buildRelativePath(project, connPoolsFile)}' to the target OBIEE server." conn connPoolsFile password repositoryPassword product obiProduct rest = useRestApi outputs.upToDateWhen { false } } } } //todo Begin Build Group New Closure project.extensions.obi.buildGroups.configureEach { bgn -> log.debug "Configuring '${bgn.name}' buildGroup" // bar task files File outputBar = project.file("$project.buildDir/bar/${bgn.getBarName()}") File outputBarDir = project.file("$project.buildDir/bar/${bgn.getBarDirName()}") log.debug "Output BAR: ${outputBar}" log.debug "Output BAR Dir: ${outputBarDir}" String repositoryPassword = getParameter("${bgn.name}Password") ?: getParameter('repositoryPassword') // BAR Sync Task taskName = bgn.getTaskName('barSync') groupName = bgn.getTaskGroup('build') if (bgn.isNonConfigTask()) { project.task(taskName, type: Sync) { group groupName description = "Synchronize the BAR build directory from SCM." from sourceBase into outputBarDir exclude '*