Index: Jenkinsfile
===================================================================
--- Jenkinsfile	(revision f9fa306f2155a870a524cc0a354eee92964debb4)
+++ Jenkinsfile	(revision 95fdb0a4a39c875125e1a0a832a8964ceeeffeb5)
@@ -10,35 +10,40 @@
 	def log_needed = false
 
-	bIsFullBuild = false
-	architectureFlag = ''
-	status_prefix = ''
+	compiler 		= compiler_from_params()
+	architecture 	= architecture_from_params()
+	
+	do_alltests		= param_allTests 	.toBoolean()
+	do_benchmark	= param_benchmark .toBoolean()
+	do_doc		= param_doc 	.toBoolean()
+	do_publish
 
 	currentBuild.result = "SUCCESS"
 
 	try {
-		//Prevent the build from exceeding 60 minutes
-		timeout(60) {
-
-			//Wrap build to add timestamp to command line
-			wrap([$class: 'TimestamperBuildWrapper']) {
+		//Wrap build to add timestamp to command line
+		wrap([$class: 'TimestamperBuildWrapper']) {
+
+			//Prevent the build from exceeding 60 minutes
+			timeout(60) {
+
+				notify()
 
 				prepare_build()
 
-				//Compile using gcc-4.9
-				currentCC = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
-				cfa_build(bIsFullBuild, architectureFlag)
-
-				//Compile latex documentation
-				doc_build()
-
-				if( bIsFullBuild ) {
-					//Compile using gcc-5
-					currentCC = new CC_Desc('gcc-5', 'g++-5', 'gcc-5')
-					cfa_build(true, architectureFlag)
-
-					//Compile using gcc-4.9
-					currentCC = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
-					cfa_build(true, architectureFlag)
-				}
+				checkout()
+
+				build()
+
+				test()
+
+				benchmark()
+
+				clean()
+
+				build_doc()
+
+				publish()
+
+				notify()
 			}
 		}
@@ -62,5 +67,5 @@
 
 		//Send email with final results if this is not a full build
-		if( !bIsFullBuild && !bIsSandbox ) {
+		if( !do_sendemail && !bIsSandbox ) {
 			echo 'Notifying users of result'
 			email(currentBuild.result, log_needed)
@@ -75,5 +80,5 @@
 
 //===========================================================================================================
-// Helper classes/variables/routines to make the status and stage name easier to use
+// Helper classes/variables/routines
 //===========================================================================================================
 //Description of a compiler (Must be serializable since pipelines are persistent)
@@ -90,17 +95,4 @@
 }
 
-//Global Variables defining the compiler and at which point in the build we are
-// These variables are used but can't be declared before hand because of wierd scripting rules
-// @Field String currentCC
-// @Field String status_prefix
-
-//Wrapper to sync stage name and status name
-def build_stage(String name) {
-	def stage_name = "${currentCC.cc_name} ${name}".trim()
-	stage stage_name
-
-		status_prefix = stage_name
-}
-
 //Helper routine to collect information about the git history
 def collect_git_info() {
@@ -121,34 +113,70 @@
 
 def prepare_build() {
-	properties ([ 									\
-		[$class: 'ParametersDefinitionProperty', 				\
-			parameterDefinitions: [ 					\
-			[$class: 'BooleanParameterDefinition',  			\
-				defaultValue: false,  					\
-				description: 'If true, the build will be promoted to the do-lang git repository (on successful builds only)', \
-				name: 'isFullBuild' 					\
-			], 								\
-			[$class: 'ChoiceParameterDefinition',				\
-				choices: '64-bit\n32-bit',					\
-				defaultValue: '64-bit',					\
-				description: 'The architecture to use for compilation',	\
-				name: 'buildArchitecture'					\
-			]]								\
+	properties ([ 													\
+		[$class: 'ParametersDefinitionProperty', 								\
+			parameterDefinitions: [ 									\
+				[$class: 'ChoiceParameterDefinition',						\
+					description: 'Which compiler to use',					\
+					name: 'param_compiler',								\
+					choices: 'gcc-6\ngcc-5\ngcc-4.9\nclang',					\
+					defaultValue: 'gcc-6',								\
+				],												\
+				[$class: 'ChoiceParameterDefinition',						\
+					description: 'The target architecture',					\
+					name: 'param_arch',								\
+					choices: '64-bit\n32-bit',							\
+					defaultValue: '64-bit',								\
+				],												\
+				[$class: 'BooleanParameterDefinition',  						\
+					description: 'If false, only the quick test suite is ran', 		\
+					name: 'param_allTests', 							\
+					defaultValue: false,  								\
+				], 												\
+				[$class: 'BooleanParameterDefinition',  						\
+					description: 'If true, jenkins also runs benchmarks', 		\
+					name: 'param_benchmark', 							\
+					defaultValue: false,  								\
+				], 												\
+				[$class: 'BooleanParameterDefinition',  						\
+					description: 'If true, jenkins also builds documentation', 		\
+					name: 'param_doc', 								\
+					defaultValue: false,  								\
+				],												\
+				[$class: 'BooleanParameterDefinition',  						\
+					description: 'If true, jenkins also publishes results', 		\
+					name: 'param_publish', 								\
+					defaultValue: false,  								\
+				],												\
+			],
 		]])
 
-	bIsFullBuild = isFullBuild == 'true'
-	architectureFlag = ''
-	if (buildArchitecture == '64-bit') {
-		architectureFlag = '--host=x86_64 CXXFLAGS="-m64" CFAFLAGS="-m64"'
-	} else if (buildArchitecture == '32-bit'){
-		architectureFlag = '--host=i386 CXXFLAGS="-m32" CFAFLAGS="-m32"'
-	} else {
-		architectureFlag = 'ERROR'
-	}
-
-	echo "FULL BUILD = ${isFullBuild}\nArchitecture = ${buildArchitecture} (flag ${architectureFlag})"
+	compiler 		= compiler_from_params()
+	architecture 	= architecture_from_params()
+
+	do_alltests		= param_allTests 	.toBoolean()
+	do_benchmark	= param_benchmark .toBoolean()
+	do_doc		= param_doc 	.toBoolean()
+	do_publish		= param_publish 	.toBoolean()
 
 	collect_git_info()
-
+}
+
+def notify() {
+	sh 'curl --data "" http://plg2:8082/jenkins/notify'
+}
+
+def make_doc() {
+	def err = null
+	try {
+		sh 'make clean > /dev/null'
+		sh 'make > /dev/null 2>&1'
+	} 
+	catch (Exception caughtError) {
+		err = caughtError //rethrow error later
+		sh 'cat *.log'
+	}
+	finally {
+		if (err) throw err // Must re-throw exception to propagate error
+	}
 }
 
@@ -157,7 +185,6 @@
 //===========================================================================================================
 //Compilation script is done here but environnement set-up and error handling is done in main loop
-def cfa_build(boolean full_build, String flags) {
-	build_stage 'Checkout'
-		def install_dir = pwd tmp: true
+def checkout() {
+	stage 'Checkout'
 		//checkout the source code and clean the repo
 		checkout scm
@@ -168,20 +195,26 @@
 		//Reset the git repo so no local changes persist
 		sh 'git reset --hard'
-
-	build_stage 'Build'
-
+}
+
+def build() {
+	stage 'Build'
+	
+		def install_dir = pwd tmp: true
+		
 		//Configure the conpilation (Output is not relevant)
 		//Use the current directory as the installation target so nothing
 		//escapes the sandbox
 		//Also specify the compiler by hand
-		sh "./configure CXX=${currentCC.cpp_cc} ${flags} --with-backend-compiler=${currentCC.cfa_backend_cc} --prefix=${install_dir} --enable-silent-rules --quiet"
+		sh "./configure CXX=${compiler.cpp_cc} ${architecture} --with-backend-compiler=${compiler.cfa_backend_cc} --prefix=${install_dir} --enable-silent-rules --quiet"
 
 		//Compile the project
 		sh 'make -j 8 --no-print-directory V=0 install'
-
-	build_stage 'Test'
+}
+
+def test() {
+	stage 'Test'
 
 		//Run the tests from the tests directory
-		if (full_build) {
+		if ( do_alltests ) {
 			sh 'make -C src/tests all-tests debug=yes'
 			sh 'make -C src/tests all-tests debug=no'
@@ -190,6 +223,10 @@
 			sh 'make -C src/tests'
 		}
-
-	build_stage 'Benchmark'
+}
+
+def benchmark() {
+	stage 'Benchmark'
+
+		if( !do_bencmark ) return
 
 		//Write the commit id to Benchmark
@@ -198,9 +235,8 @@
 		//Append bench results
 		sh 'make -C src/benchmark --no-print-directory csv-data >> bench.csv'
-
-		//Then publish the results
-		sh 'curl --data @bench.csv http://plg2/~cforall/cgi-bin/publish.cgi'
-
-	build_stage 'Cleanup'
+}
+
+def clean() {
+	stage 'Cleanup'
 
 		//do a maintainer-clean to make sure we need to remake from scratch
@@ -208,31 +244,8 @@
 }
 
-def make_doc() {
-	def err = null
-
-	try {
-		sh 'make clean > /dev/null'
-		sh 'make > /dev/null 2>&1'
-	}
-
-	catch (Exception caughtError) {
-		//rethrow error later
-		err = caughtError
-
-		sh 'cat *.log'
-	}
-
-	finally {
-		/* Must re-throw exception to propagate error */
-		if (err) {
-			throw err
-		}
-	}
-}
-
-def doc_build() {
+def build_doc() {
 	stage 'Documentation'
 
-		status_prefix = 'Documentation'
+		if( !do_doc ) return
 
 		dir ('doc/user') {
@@ -243,4 +256,13 @@
 			make_doc()
 		}
+}
+
+def publish() {
+	stage 'Publish'
+
+		if( !do_publish ) return
+
+		//Then publish the results
+		sh 'curl --data @bench.csv http://plg2:8082/jenkins/publish'
 }
 
