FreeBSDQt5.12.template 7.57 KB
Newer Older
1 2 3
// Provisionally mark the build as successful
currentBuild.result = 'SUCCESS'

4
// Request a node to be allocated to us
5
node( currentPlatform ) {
6 7 8 9
// 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 {
10 11
		// First Thing: Checkout Sources
		stage('Checkout Sources') {
12 13
			// Make sure we have a clean slate to begin with
			deleteDir()
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
		
			// Actual Application Sources
			checkout changelog: true, poll: true, scm: [
				$class: 'GitSCM',
				branches: [[name: branchToBuild]],
				browser: [$class: 'CGit', repoUrl: browserUrl],
				extensions: [[$class: 'CloneOption', timeout: 120]],
				userRemoteConfigs: [[url: repositoryUrl]]
			]

			// Our CI scripts
			checkout changelog: false, poll: false, scm: [
				$class: 'GitSCM',
				branches: [[name: 'master']],
				extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'ci-tooling/']],
29
				userRemoteConfigs: [[url: 'https://anongit.kde.org/sysadmin/ci-tooling']]
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
			]

			// 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
55
			sh "python3 -u ci-tooling/helpers/prepare-dependencies.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --environment ${ciEnvironment} --platform ${currentPlatform} --installTo '$HOME/install-prefix/'"
56 57 58 59 60
		}

		// 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
61
			sh "python3 -u ci-tooling/helpers/configure-build.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --installTo '$HOME/install-prefix/'"
62 63 64 65 66
		}

		// 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
67
			sh "python3 -u ci-tooling/helpers/compile-build.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --usingInstall '$HOME/install-prefix/'"
68 69 70 71 72 73
		}

		// 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
74
			sh "python3 -u ci-tooling/helpers/install-build.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --installTo '$HOME/install-prefix/' --divertTo '$WORKSPACE/install-divert/'"
75 76 77 78 79 80 81 82
		}

		// Looks like it built okay - let's capture this for later use
		// We'll also take the opportunity to extract metadata from CMake used by packagers and api.kde.org
		stage('Capturing Installation') {
			// First we create a tar archive of the installation which was diverted
			// Then we upload a copy of that to the master server and have it publish the new archive
			// Finally to save bandwidth our copy of the tar archive is moved to our local cache for reuse on later builds on this node
83
			sh "python3 -u ci-tooling/helpers/capture-install.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --environment ${ciEnvironment} --platform ${currentPlatform} --divertedTo '$WORKSPACE/install-divert/' --installedTo '$HOME/install-prefix/'"
84 85 86 87 88 89
		}

		// 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)
90
			sh "python3 -u ci-tooling/helpers/run-tests.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform} --usingInstall '$HOME/install-prefix/'"
91 92 93 94 95 96 97 98 99 100 101

			// Collect our results
			junit allowEmptyResults: true, testResults: 'JUnitTestResults.xml'
		}

		// Final thing to do: some code quality checks
		stage('Checking Code Quality') {

			// cppcheck is not supported by Pipeline at the moment, so we don't run that for now
			// See https://issues.jenkins-ci.org/browse/JENKINS-35096

102 103
			// Perform Cobertura Processing
			// First, run the LCov extraction
104
			sh "python3 -u ci-tooling/helpers/extract-lcov-results.py --product ${productName} --project ${projectName} --branchGroup ${branchGroup} --platform ${currentPlatform}"
105 106 107 108 109 110 111 112 113 114 115

			// 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
			])
116 117

			// Scan the logs and publish a warnings report
118
			warnings consoleParsers: [[parserName: 'Clang (LLVM based)']], excludePattern: "/tmp/**"
119 120 121

		}

122 123 124 125 126 127 128
	}

	// Let's determine if we need to send out notifications
	// What happened in our previous build?
	def previousResult = currentBuild.previousBuild?.result
	// If our condition has changed, is FAILURE or UNSTABLE then we want to send an email
	if( previousResult != currentBuild.result || currentBuild.result == 'FAILURE' || currentBuild.result == 'UNSTABLE' ) {
129 130 131 132 133 134 135 136 137 138
		// Start constructing the list of our recipients
		// At this point we can only be either a failure or an unstable build, so notify those who have requested unstable build notifications
		def mailTo = [ unstableBuildEmails ]

		// If the build was a solid failure (either now or previously) then notify those who want to know about failures only
		if( previousResult == 'FAILURE' || currentBuild.result == 'FAILURE' ) {
			// Add them to the list
			mailTo << buildFailureEmails
		}

139 140
		// If someone kicked this job off, they're presumably interested as well
		mailTo << emailextrecipients( [[$class: 'RequesterRecipientProvider']] )
141 142 143
		// We always want to notify our dashboard as well
		mailTo << "kde-dashboard@kde.org"

144 145 146 147 148 149 150 151
		// Finalise the list of recipients
		mailTo = mailTo.join(',')

		// Send the email now
		emailext(
			to: mailTo,
			body: '${JELLY_SCRIPT,template="html_gmail"}',
			mimeType: 'text/html',
152
			subject: 'KDE CI: ${PROJECT_NAME} - Build # ${BUILD_NUMBER} - ${BUILD_STATUS}!', 
153
			attachLog: false
154
		)
155
	}
156 157 158 159 160 161

	// IRC Notifications are currently not supported by Pipeline
	// See https://issues.jenkins-ci.org/browse/JENKINS-33922
	// We can probably workaround this using Pursuivant and the emails Jenkins sends out
	// This would allow subscribing to build notifications for IRC channels in much the same way one subscribes for Commits and Bugzilla changes

162
	// As the FreeBSD Slaves are permanent ones, we erase the Workspace
163
	deleteDir()
164 165
	// Along with the installation prefix, which lives outside the Workspace
	sh "rm -rf $HOME/install-prefix/"
166

167
}
168
}