From 8360fc4cf7a5f01835f99ac1398b13970baa0c9e Mon Sep 17 00:00:00 2001 From: Andrei Gheorghiu Date: Wed, 14 Sep 2016 14:35:45 +0200 Subject: multibranch test 0.2 --- Jenkinsfile | 91 ++++++--------------------------------------------------- Jenkinsfile_old | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 82 deletions(-) create mode 100644 Jenkinsfile_old diff --git a/Jenkinsfile b/Jenkinsfile index 7bb5422..04aba0b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,84 +1,11 @@ -// Defining the closure to be used for building a target - -def target_build = {machine-> - print "This is the build for target $machine" - // sh 'mkdir $machine' - // dir ('$machine') { - // pwd() - // unstash 'eltf_scripts' - // } - } - -def constructor_function(trg) {{it->print "This is another build for the target $trg"}} - -node { - // Start the fist stage which sets up the pipeline environment - stage 'Set up environment' - // Cleaning the workspace - deleteDir() - - // The first step is to freeze the manifest repositiries - print "To add a job to freeze the manifest repositories" - - def targets = TARGET_LIST.split(',') - for (item in targets) {print item} - - // Old implementation of the git clone. Changed as it does not support target directory - //git url: 'git@git.enea.se:eltf/scripts.git', branch: 'master', relativeTargetDir: 'eltf_scripts' - - // Clone eltf/scripts.git repository - checkout([$class: 'GitSCM', - branches: [[name: '*/master']], - doGenerateSubmoduleConfigurations: false, - extensions: [[$class: 'RelativeTargetDirectory', - relativeTargetDir: 'eltf_scripts']], - submoduleCfg: [], - userRemoteConfigs: [[url: 'git@git.enea.se:eltf/scripts.git']]]) - - // Stash the ELTF scripts in order to be used on other nodes - stash includes: 'eltf_scripts/*', name: 'eltf_scripts', useDefaultExcludes: false - - // Start the next stages for Build, Test and Document - - stage 'Build' - - build_jobs = [:] - for (item in targets){build_jobs.put(item, constructor_function(item))} - print "I am here" - - try { - parallel build_jobs - } - catch (java.io.NotSerializableException stupid_error){ - - print "Finished parallel step and entered the catch statement" - print stupid_error - //stage 'Test' - print "hello from stage 3" - } - try { - stage 'Document' - print "hello from stage 4" - stage 'Build Documentation' - print "hello from stage 5" - stage 'Build Release Candidate' - echo "hello...it's me...:)" - stage 'Publish Release Candidate' - def PUBLISH_RC = input( - id: 'PUBLISH_RC', message: 'Publish RC?', ok: 'Yes', parameters: [ - [$class: 'StringParameterDefinition', defaultValue: 'RC1', description: 'This is the RC number to be published', name: 'RC_NUMBER'], - [$class: 'StringParameterDefinition', defaultValue: 'EL6_RC2', description: 'This is the tag to be applied in the manifest repo', name: 'RC_TAG'] - ]) - echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) - print "hello from stage 5" - echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) - stage 'Pubilsh Official Release' - echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) - } - catch (err) { - print err - } - } - +#!/bin/env groovy +node ('master') { + println 'in node master: ' + sh 'env' +} +node ('builder') { + println 'in node builder: ' + sh 'env' +} diff --git a/Jenkinsfile_old b/Jenkinsfile_old new file mode 100644 index 0000000..7bb5422 --- /dev/null +++ b/Jenkinsfile_old @@ -0,0 +1,84 @@ +// Defining the closure to be used for building a target + +def target_build = {machine-> + print "This is the build for target $machine" + // sh 'mkdir $machine' + // dir ('$machine') { + // pwd() + // unstash 'eltf_scripts' + // } + } + +def constructor_function(trg) {{it->print "This is another build for the target $trg"}} + +node { + // Start the fist stage which sets up the pipeline environment + stage 'Set up environment' + // Cleaning the workspace + deleteDir() + + // The first step is to freeze the manifest repositiries + print "To add a job to freeze the manifest repositories" + + def targets = TARGET_LIST.split(',') + for (item in targets) {print item} + + // Old implementation of the git clone. Changed as it does not support target directory + //git url: 'git@git.enea.se:eltf/scripts.git', branch: 'master', relativeTargetDir: 'eltf_scripts' + + // Clone eltf/scripts.git repository + checkout([$class: 'GitSCM', + branches: [[name: '*/master']], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'RelativeTargetDirectory', + relativeTargetDir: 'eltf_scripts']], + submoduleCfg: [], + userRemoteConfigs: [[url: 'git@git.enea.se:eltf/scripts.git']]]) + + // Stash the ELTF scripts in order to be used on other nodes + stash includes: 'eltf_scripts/*', name: 'eltf_scripts', useDefaultExcludes: false + + // Start the next stages for Build, Test and Document + + stage 'Build' + + build_jobs = [:] + for (item in targets){build_jobs.put(item, constructor_function(item))} + print "I am here" + + try { + parallel build_jobs + } + catch (java.io.NotSerializableException stupid_error){ + + print "Finished parallel step and entered the catch statement" + print stupid_error + //stage 'Test' + print "hello from stage 3" + } + try { + stage 'Document' + print "hello from stage 4" + stage 'Build Documentation' + print "hello from stage 5" + stage 'Build Release Candidate' + echo "hello...it's me...:)" + stage 'Publish Release Candidate' + def PUBLISH_RC = input( + id: 'PUBLISH_RC', message: 'Publish RC?', ok: 'Yes', parameters: [ + [$class: 'StringParameterDefinition', defaultValue: 'RC1', description: 'This is the RC number to be published', name: 'RC_NUMBER'], + [$class: 'StringParameterDefinition', defaultValue: 'EL6_RC2', description: 'This is the tag to be applied in the manifest repo', name: 'RC_TAG'] + ]) + echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) + print "hello from stage 5" + echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) + stage 'Pubilsh Official Release' + echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) + } + catch (err) { + print err + } + } + + + -- cgit v1.2.3-54-g00ecf