Add a "noTests" config parameter

Add a new configuration parameter to skip tests and static checks.
If true, also skip reporting. By default false.

This can be used to make builds do only the bare minimum to produce
JARs and a p2 update site.

This is intended for exceptional use only, for instance if the CI
infrastructure is overloaded or otherwise has problems, or unstable
tests make build fails constantly, and you need to get a release out
of the door. It is assumed that tests have been run locally.

Change-Id: I120ab054c625de48ef67a041e70b9be6901b3b08
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
diff --git a/src/org/eclipse/egit/jenkins/Tools.groovy b/src/org/eclipse/egit/jenkins/Tools.groovy
index 084b87b..9a71ec1 100644
--- a/src/org/eclipse/egit/jenkins/Tools.groovy
+++ b/src/org/eclipse/egit/jenkins/Tools.groovy
@@ -136,16 +136,13 @@
 	}
 
 	/**
-	 * Standard EGit build reporting steps, including artifact archiving.
+	 * Archives build artifacts. Screenshots from failed tests and Eclipse logs are added automatically.
 	 *
 	 * @param specificArtifacts
 	 * 		Collection of ${WORKSPACE}-relative ant patterns defining the artifacts to archive;
 	 * 		screenshots and Eclipse log files are added automatically
 	 */
-	def void reporting(Collection specificArtifacts = []) {
-		// don't use ** if the number of directories is known, this is a huge performance problem
-		script.junit '*/target/surefire-reports/*.xml'
-
+	def void archiveArtifacts(Collection specificArtifacts = []) {
 		def artifacts = []
 		artifacts.addAll(specificArtifacts)
 		artifacts.addAll([
@@ -153,6 +150,14 @@
 			'*/target/work/data/.metadata/*log',
 		])
 		script.archiveArtifacts artifacts.join(',')
+	}
+
+	/**
+	 * Standard EGit build reporting steps.
+	 */
+	def void reporting() {
+		// don't use ** if the number of directories is known, this is a huge performance problem
+		script.junit '*/target/surefire-reports/*.xml'
 
 		// TODO replace by warnings-next-generation once it is installed
 		script.findbugs pattern: '*/target/*bugsXml.xml', defaultEncoding: 'UTF-8'
diff --git a/vars/productBuild.groovy b/vars/productBuild.groovy
index f2346ac..0841f48 100644
--- a/vars/productBuild.groovy
+++ b/vars/productBuild.groovy
@@ -24,7 +24,7 @@
  * @return
  */
 def call(def lib, def tooling, Map cfg = [:]) {
-	Map config = [timeOut : 60] << cfg
+	Map config = [timeOut : 60, noTests : false] << cfg
 	// Check parameters
 	lib.configCheck(config, [
 		timeOut : 'Job timeout in minutes, default 60',
@@ -58,8 +58,10 @@
 			if (!upstreamVersion) {
 				upstreamVersion = lib.getUpstreamVersion(config.upstreamRepoPath, config.upstreamRepo, ownVersion)
 			}
+			def profiles = config.noTests ? '' : 'static-checks,'
+			profiles += 'other-os,eclipse-sign'
 			def commonMvnArguments = [
-				'-Pstatic-checks,other-os,eclipse-sign',
+				'-P' + profiles,
 				lib.getMvnUpstreamRepo(config.upstreamRepo, upstreamVersion),
 				// Needed by tycho-eclipserun for the p2 mirrors URL
 				"-DPUBLISH_FOLDER=${publishFolder}"
@@ -70,6 +72,9 @@
 					'install'
 				]
 				arguments.addAll(commonMvnArguments)
+				if (config.noTests) {
+					arguments.add('-DskipTests=true')
+				}
 				tooling.maven(arguments)
 			}
 			stage('Deploy') {
@@ -106,9 +111,12 @@
 		}
 		finally { // replacement for post actions of Jenkins 1.x
 			stage('Results') {
-				tooling.reporting([
+				tooling.archiveArtifacts([
 					config.p2project + '/target/repository/**'
 				])
+				if (!config.noTests) {
+					tooling.reporting()
+				}
 			}
 			tooling.sendMail('egit-build@eclipse.org')
 		}
diff --git a/vars/verifyBuild.groovy b/vars/verifyBuild.groovy
index c8f6b33..2d154b1 100644
--- a/vars/verifyBuild.groovy
+++ b/vars/verifyBuild.groovy
@@ -23,7 +23,7 @@
  * @return
  */
 def call(def lib, def tooling, Map cfg = [:]) {
-	Map config = [timeOut : 60] << cfg
+	Map config = [timeOut : 60, noTests : false] << cfg
 	// Check parameters
 	lib.configCheck(config, [
 		timeOut : 'Job timeout in minutes, default 60',
@@ -59,20 +59,28 @@
 				if (!upstreamVersion) {
 					upstreamVersion = lib.getUpstreamVersion(config.upstreamRepoPath, config.upstreamRepo, ownVersion)
 				}
+				def profiles = config.noTests ? '' : 'static-checks,'
+				profiles += 'other-os,eclipse-sign'
 				def arguments = [
 					'clean',
 					'install',
-					'-Pstatic-checks,other-os,eclipse-sign',
+					'-P' + profiles,
 					lib.getMvnUpstreamRepo(config.upstreamRepo, upstreamVersion)
 				]
+				if (config.noTests) {
+					arguments.add('-DskipTests=true')
+				}
 				tooling.maven(arguments)
 			}
 		}
 		finally { // replacement for post actions of Jenkins 1.x
 			stage('Results') {
-				tooling.reporting([
+				tooling.archiveArtifacts([
 					config.p2project + '/target/repository/**'
 				])
+				if (!config.noTests) {
+					tooling.reporting()
+				}
 			}
 		}
 	}