diff --git a/pre-review/create_review_job.groovy b/pre-review/create_review_job.groovy index 32a7137..246bd5f 100644 --- a/pre-review/create_review_job.groovy +++ b/pre-review/create_review_job.groovy @@ -1,69 +1,70 @@ // Overall configuration // As developers might be posting reviews for master or stable branches, we'll build against master // While not perfect, this is the best solution we have for now def branchGroup = "kf5-qt5" def ciEnvironment = "production" // Read in our variables, as we'll need to know what job we are creating... def productName = "${PRODUCT_NAME}" def reviewID = "${DIFF_ID}" def reviewPHID = "${PHID}" def reviewStagingURL = "${STAGING_URI}" def reviewStagingRef = "${STAGING_REF}" // Determine which repository we have here -def projectName = reviewStagingURL.tokenize('/').last() +def repositoryName = reviewStagingURL.tokenize(':').last() +def projectName = repositoryName.tokenize('.').first() // Create a name for this job def jobName = "Reviews/${reviewID}" // Read in the necessary Pipeline template def pipelineTemplate = readFileFromWorkspace("pre-review/review-build.template") // Now we can construct our Pipeline script // We append a series of variables to the top of it to provide a variety of useful information to the otherwise templated script // These appended variables are what makes one build different to the next, aside from the template which was used def pipelineScript = """ |def repositoryUrl = "${reviewStagingURL}" |def branchToBuild = "${reviewStagingRef}" |def productName = "${productName}" |def projectName = "${projectName}" |def branchGroup = "${branchGroup}" |def ciEnvironment = "${ciEnvironment}" |${pipelineTemplate}""".stripMargin() // Actually create the job now pipelineJob( jobName ) { // In order to be able to report back to PHabricator, we'll need to know a few things // Like the Differential ID number (we technically already do, but the Phabricator plugin expects to see it as a parameter) parameters { stringParam('DIFF_ID') stringParam('PHID') } properties { // We don't want to keep build results forever // We'll set it to keep the last 25 builds and discard everything else buildDiscarder { strategy { logRotator { numToKeepStr("5") daysToKeepStr('') artifactDaysToKeepStr('') artifactNumToKeepStr('') } } } // We don't want to be building the same project more than once // This is to prevent one project hogging resources // And also has a practical component as otherwise an older build could finish afterwards and upload old build results disableConcurrentBuilds() } // This is where the Pipeline script actually happens :) definition { cps { script( pipelineScript ) sandbox() } } } diff --git a/pre-review/review-build.template b/pre-review/review-build.template index 4239f98..8803974 100644 --- a/pre-review/review-build.template +++ b/pre-review/review-build.template @@ -1,112 +1,115 @@ // Provisionally mark the build as successful currentBuild.result = 'SUCCESS' // Request a node to be allocated to us node( "SUSEQt5.10" ) { // We want Timestamps on everything timestamps { // We want to catch any errors that occur to allow us to send out notifications (ie. emails) if needed catchError { + // Make sure everything knows this is a SUSE Qt 5.10 build + def currentPlatform = "SUSEQt5.10" + // First Thing: Checkout Sources stage('Checkout Sources') { // Actual Application Sources checkout changelog: true, poll: true, scm: [ $class: 'GitSCM', branches: [[name: branchToBuild]], extensions: [[$class: 'CloneOption', timeout: 120]], userRemoteConfigs: [[url: repositoryUrl, credentialsId: '0fd04262-ed87-437f-a93a-1f709c0eada4']] ] // Our CI scripts checkout changelog: false, poll: false, scm: [ $class: 'GitSCM', branches: [[name: 'master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'ci-tooling/']], userRemoteConfigs: [[url: 'https://anongit.kde.org/sysadmin/ci-tooling']] ] // Projects metadata and next generation dependency metadata checkout changelog: false, poll: false, scm: [ $class: 'GitSCM', branches: [[name: 'master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'ci-tooling/repo-metadata/']], userRemoteConfigs: [[url: 'https://anongit.kde.org/sysadmin/repo-metadata']] ] // Dependency Metadata checkout changelog: false, poll: false, scm: [ $class: 'GitSCM', branches: [[name: 'master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'ci-tooling/kde-build-metadata/']], userRemoteConfigs: [[url: 'https://anongit.kde.org/kde-build-metadata']] ] } // Now Prepare to Build: Get the dependencies ready stage('Setup Dependencies') { // Now we can determine what our dependencies are // Then update to the latest version of the dependencies available from the master server // Finally extract all of those dependencies in turn into the given 'installTo' directory sh "python3 -u ci-tooling/helpers/prepare-dependencies.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --environment ${ciEnvironment} --platform ${currentPlatform} --installTo '$HOME/install-prefix/'" } // Now we can configure our build stage('Configuring Build') { // This is delegated through a helper script to handle minor special cases like inSourceBuilds, non-CMake build systems, etc sh "python3 -u ci-tooling/helpers/configure-build.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --installTo '$HOME/install-prefix/'" } // Finally we can build it! (Once again, through a helper) stage('Compiling') { // We use a helper here so we can determine the appropriate number of CPUs (-j) to build with sh "python3 -u ci-tooling/helpers/compile-build.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --usingInstall '$HOME/install-prefix/'" } // Now we can run our tests stage('Running Tests') { // Run the unit tests for this project // Tests are run in a basic environment (X, DBus) sh "python3 -u ci-tooling/helpers/run-tests.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --usingInstall '$HOME/install-prefix/'" // Collect our results junit allowEmptyResults: true, testResults: 'JUnitTestResults.xml' } // Now ensure that it installs.... stage('Installing') { // The helper ensures that DESTDIR and INSTALL_ROOT are set to 'divertTo' // This allows us to capture the install at the next stage for later reuse in the Setup Dependencies step sh "python3 -u ci-tooling/helpers/install-build.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --installTo '$HOME/install-prefix/'" } // Final thing to do: some code quality checks stage('Checking Code Quality') { // Perform Cobertura Processing // First, run the LCov extraction sh "python3 -u ci-tooling/helpers/extract-lcov-results.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform}" // Collect the results from the LCov extraction step([ $class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'CoberturaLcovResults.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false ]) // Scan the logs and publish a warnings report warnings consoleParsers: [[parserName: 'GNU Make + GNU C Compiler (gcc)'], [parserName: 'Appstreamercli']], excludePattern: "/tmp/**" } } // Finally, we inform Phabricator of everything that has occurred //step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true]) } }