diff options
-rw-r--r-- | Jenkinsfile | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..bf06986 --- /dev/null +++ b/Jenkinsfile | |||
@@ -0,0 +1,84 @@ | |||
1 | // Defining the closure to be used for building a target | ||
2 | |||
3 | def target_build = {machine-> | ||
4 | print "This is the build for target $machine" | ||
5 | // sh 'mkdir $machine' | ||
6 | // dir ('$machine') { | ||
7 | // pwd() | ||
8 | // unstash 'eltf_scripts' | ||
9 | // } | ||
10 | } | ||
11 | |||
12 | def constructor_function(trg) {{it->print "This is another build for the target $trg"}} | ||
13 | |||
14 | node { | ||
15 | // Start the fist stage which sets up the pipeline environment | ||
16 | stage 'Set up environment' | ||
17 | // Cleaning the workspace | ||
18 | deleteDir() | ||
19 | |||
20 | // The first step is to freeze the manifest repositiries | ||
21 | print "To add a job to freeze the manifest repositories" | ||
22 | |||
23 | def targets = TARGET_LIST.split(',') | ||
24 | for (item in targets) {print item} | ||
25 | |||
26 | // Old implementation of the git clone. Changed as it does not support target directory | ||
27 | //git url: 'git@git.enea.se:eltf/scripts.git', branch: 'master', relativeTargetDir: 'eltf_scripts' | ||
28 | |||
29 | // Clone eltf/scripts.git repository | ||
30 | checkout([$class: 'GitSCM', | ||
31 | branches: [[name: '*/master']], | ||
32 | doGenerateSubmoduleConfigurations: false, | ||
33 | extensions: [[$class: 'RelativeTargetDirectory', | ||
34 | relativeTargetDir: 'eltf_scripts']], | ||
35 | submoduleCfg: [], | ||
36 | userRemoteConfigs: [[url: 'git@git.enea.se:eltf/scripts.git']]]) | ||
37 | |||
38 | // Stash the ELTF scripts in order to be used on other nodes | ||
39 | stash includes: 'eltf_scripts/*', name: 'eltf_scripts', useDefaultExcludes: false | ||
40 | |||
41 | // Start the next stages for Build, Test and Document | ||
42 | |||
43 | stage 'Build' | ||
44 | |||
45 | build_jobs = [:] | ||
46 | for (item in targets){build_jobs.put(item, constructor_function(item))} | ||
47 | print "I am here" | ||
48 | |||
49 | try { | ||
50 | parallel build_jobs | ||
51 | } | ||
52 | catch (java.io.NotSerializableException stupid_error){ | ||
53 | |||
54 | 1,1 Top | ||
55 | print "Finished parallel step and entered the catch statement" | ||
56 | print stupid_error | ||
57 | //stage 'Test' | ||
58 | print "hello from stage 3" | ||
59 | } | ||
60 | try { | ||
61 | stage 'Document' | ||
62 | print "hello from stage 4" | ||
63 | stage 'Build Documentation' | ||
64 | print "hello from stage 5" | ||
65 | stage 'Build Release Candidate' | ||
66 | echo "hello...it's me...:)" | ||
67 | stage 'Publish Release Candidate' | ||
68 | def PUBLISH_RC = input( | ||
69 | id: 'PUBLISH_RC', message: 'Publish RC?', ok: 'Yes', parameters: [ | ||
70 | [$class: 'StringParameterDefinition', defaultValue: 'RC1', description: 'This is the RC number to be published', name: 'RC_NUMBER'], | ||
71 | [$class: 'StringParameterDefinition', defaultValue: 'EL6_RC2', description: 'This is the tag to be applied in the manifest repo', name: 'RC_TAG'] | ||
72 | ]) | ||
73 | echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) | ||
74 | print "hello from stage 5" | ||
75 | echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) | ||
76 | stage 'Pubilsh Official Release' | ||
77 | echo ("The RC number is: "+PUBLISH_RC['RC_NUMBER']) | ||
78 | } | ||
79 | catch (err) { | ||
80 | print err | ||
81 | } | ||
82 | } | ||
83 | |||
84 | |||