summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Scrieciu <catalin.scrieciu@enea.com>2016-07-14 14:44:48 +0200
committerCatalin Scrieciu <catalin.scrieciu@enea.com>2016-07-14 14:44:48 +0200
commit22b47078158182d94f567ea5f1f569c3f4189c4c (patch)
treefdc48f1a770ed0297639a8f51e91b41b80c995bd
parent0e41a4648c642235597bf9f994232295b8adfa86 (diff)
downloadel_manifests-standard-22b47078158182d94f567ea5f1f569c3f4189c4c.tar.gz
test
-rw-r--r--Jenkinsfile185
1 files changed, 108 insertions, 77 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index bf06986..50e0d09 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,84 +1,115 @@
1// Defining the closure to be used for building a target 1port groovy.io.FileType
2 2
3def target_build = {machine-> 3@NonCPS def getTargets(){
4 print "This is the build for target $machine" 4 targetList = []
5 // sh 'mkdir $machine' 5 dirList = new File(pwd()+'/manifest_repo/.repo/manifests/')
6 // dir ('$machine') { 6 dirList.eachFile { file -> if (file.directory && file.name!='.git' && file.name!='common'){targetList.add file.name}}
7 // pwd() 7 return targetList
8 // unstash 'eltf_scripts' 8}
9 // }
10 }
11 9
12def constructor_function(trg) {{it->print "This is another build for the target $trg"}} 10def targetBuild(trg){
13 11 {
14node { 12 target=trg-> node{
15 // Start the fist stage which sets up the pipeline environment 13 sh 'mkdir trg'
16 stage 'Set up environment' 14 dir ('$trg'){
17 // Cleaning the workspace 15 unstash 'eltf_scripts'
18 deleteDir() 16 checkout([$class: 'RepoScm',
19 17 currentBranch: true,
20 // The first step is to freeze the manifest repositiries 18 manifestBranch: '$BRANCH_NAME',
21 print "To add a job to freeze the manifest repositories" 19 manifestFile: '$trg/default.xml',
22 20 //The hardcoded repository should be replaced by a generic name, eg. $GIT_PATH+el_manifests-$PROFILE
23 def targets = TARGET_LIST.split(',') 21 manifestRepositoryUrl: 'http://git.enea.se/cgit/various/el_manifests-standard.git',
24 for (item in targets) {print item} 22 quiet: true,
25 23 showAllChanges: true,
26 // Old implementation of the git clone. Changed as it does not support target directory 24 trace: true])
27 //git url: 'git@git.enea.se:eltf/scripts.git', branch: 'master', relativeTargetDir: 'eltf_scripts' 25 checkout([$class: 'GitSCM',
28 26 branches: [[name: '$BRANCH_NAME']],
29 // Clone eltf/scripts.git repository 27 doGenerateSubmoduleConfigurations: false,
30 checkout([$class: 'GitSCM', 28 extensions: [[$class: 'RelativeTargetDirectory',
31 branches: [[name: '*/master']], 29 relativeTargetDir: 'poky/'],
32 doGenerateSubmoduleConfigurations: false, 30 [$class: 'AuthorInChangelog']],
33 extensions: [[$class: 'RelativeTargetDirectory', 31 submoduleCfg: [],
34 relativeTargetDir: 'eltf_scripts']], 32 userRemoteConfigs: [[credentialsId: 'a797f854-983e-473e-b221-6d8ebafda16a',
35 submoduleCfg: [], 33 url: 'git@git.enea.se:linux/meta-enea-test.git']]])
36 userRemoteConfigs: [[url: 'git@git.enea.se:eltf/scripts.git']]]) 34 }
37 35 }
38 // Stash the ELTF scripts in order to be used on other nodes 36 }
39 stash includes: 'eltf_scripts/*', name: 'eltf_scripts', useDefaultExcludes: false 37}
40
41 // Start the next stages for Build, Test and Document
42
43 stage 'Build'
44 38
45 build_jobs = [:] 39/*
46 for (item in targets){build_jobs.put(item, constructor_function(item))} 40Defining the first stage of the pipeline.
47 print "I am here" 41This stage prepares the workspace and the build environment, clones ELTF scripts and
42stashes them in order to be used on all distrubuted nodes.
43This stage is also determining needed information like the targets to be built/tested.
44*/
48 45
49 try { 46stage 'Environment Setup'
50 parallel build_jobs 47node {
51 } 48 // Delete workspace content before running any step
52 catch (java.io.NotSerializableException stupid_error){ 49 deleteDir()
50
51 // Freeze manifest files before running builds
52 print "To add a job to freeze the manifest repositories"
53
54 // Clone eltf/scripts.git repository
55 checkout([$class: 'GitSCM',
56 branches: [[name: '*/master']],
57 doGenerateSubmoduleConfigurations: false,
58 extensions: [[$class: 'RelativeTargetDirectory',relativeTargetDir: 'eltf_scripts']],
59 submoduleCfg: [],
60 userRemoteConfigs: [[url: 'git@git.enea.se:eltf/scripts.git']]])
53 61
54 1,1 Top 62 // Stash the ELTF scripts in order to be used on other nodes
55 print "Finished parallel step and entered the catch statement" 63 stash includes: 'eltf_scripts/*', name: 'eltf_scripts', useDefaultExcludes: false
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 64
65 // Clone manifest repository in order to determine target list
66 checkout([$class: 'RepoScm',
67 currentBranch: true,
68 destinationDir: 'manifest_repo',
69 manifestBranch: 'master',
70 manifestRepositoryUrl: 'http://git.enea.se/cgit/various/el_manifests-standard.git',
71 showAllChanges: true,
72 trace: true])
73
74 // Parse directory structure in order to determine the target list
75 targetList = getTargets()
76 for (item in targetList) {print item}
77
78 print 'Finished stage Environment Setup'
79}
84 80
81stage 'Build'
82// Create the build map which defines the build threads
83def buildMap = [:]
84for (item in targetList){
85 def id = item+'_build'
86 buildMap[id] = targetBuild(item)
87}
88parallel buildMap
89node {
90 print 'Finished stage Build'
91}
92stage 'Test'
93node {
94 print 'Finished stage Test'
95}
96stage 'Document'
97node {
98 print 'Finished stage Document'
99}
100stage 'Build Documentation'
101node {
102 print 'Finished stage Build Documentation'
103}
104stage 'Build Release Candidate'
105node {
106 print 'Finished stage Build RC'
107}
108stage 'Publish Release Candidate'
109node {
110 print 'Finished stage Publish RC'
111}
112stage 'Publish official Release'
113node {
114 print 'Finished stage Publish Release'
115}