diff options
-rw-r--r-- | Jenkinsfile | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/Jenkinsfile b/Jenkinsfile index c69fc5e..f6c4cfd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile | |||
@@ -1,4 +1,19 @@ | |||
1 | import groovy.io.FileType | 1 | import groovy.io.FileType |
2 | =====USER DEFINED VARIABLES===== | ||
3 | def images_to_buid = ['enea-image-'+profile','enea-image-'+profile+'-sdk', 'world'] | ||
4 | def localGitRoot = 'http://git.enea.se/cgit/various/' | ||
5 | def publicGitRoot = 'http://git.enea.com/cgit/linux/' | ||
6 | |||
7 | =====USER DEFINED FUNCTIONS===== | ||
8 | |||
9 | def getProfile(){ | ||
10 | return 'standard' | ||
11 | } | ||
12 | |||
13 | def getReleaseLayer(){ | ||
14 | releaseLayer = 'meta-el-'+getProfile() | ||
15 | return releaseLayer | ||
16 | } | ||
2 | 17 | ||
3 | @NonCPS def getTargets(){ | 18 | @NonCPS def getTargets(){ |
4 | targetList = [] | 19 | targetList = [] |
@@ -7,6 +22,21 @@ import groovy.io.FileType | |||
7 | return targetList | 22 | return targetList |
8 | } | 23 | } |
9 | 24 | ||
25 | def imageBuild(){ | ||
26 | print 'test' | ||
27 | } | ||
28 | |||
29 | def imageBuild(machine, profile, buildStamp, releaseLayer){ | ||
30 | { | ||
31 | it-> node{ | ||
32 | print machine | ||
33 | print profile | ||
34 | print buildStamp | ||
35 | print releaseLayer | ||
36 | } | ||
37 | } | ||
38 | } | ||
39 | |||
10 | def targetBuild(trg){ | 40 | def targetBuild(trg){ |
11 | { | 41 | { |
12 | target=trg-> node{ | 42 | target=trg-> node{ |
@@ -16,7 +46,7 @@ def targetBuild(trg){ | |||
16 | checkout([$class: 'RepoScm', | 46 | checkout([$class: 'RepoScm', |
17 | currentBranch: true, | 47 | currentBranch: true, |
18 | manifestBranch: '$BRANCH_NAME', | 48 | manifestBranch: '$BRANCH_NAME', |
19 | manifestFile: trg+'default.xml', | 49 | manifestFile: trg+'/default.xml', |
20 | //The hardcoded repository should be replaced by a generic name, eg. $GIT_PATH+el_manifests-$PROFILE | 50 | //The hardcoded repository should be replaced by a generic name, eg. $GIT_PATH+el_manifests-$PROFILE |
21 | manifestRepositoryUrl: 'http://git.enea.se/cgit/various/el_manifests-standard.git', | 51 | manifestRepositoryUrl: 'http://git.enea.se/cgit/various/el_manifests-standard.git', |
22 | quiet: true, | 52 | quiet: true, |
@@ -31,11 +61,20 @@ def targetBuild(trg){ | |||
31 | submoduleCfg: [], | 61 | submoduleCfg: [], |
32 | userRemoteConfigs: [[credentialsId: 'a797f854-983e-473e-b221-6d8ebafda16a', | 62 | userRemoteConfigs: [[credentialsId: 'a797f854-983e-473e-b221-6d8ebafda16a', |
33 | url: 'git@git.enea.se:linux/meta-enea-test.git']]]) | 63 | url: 'git@git.enea.se:linux/meta-enea-test.git']]]) |
64 | stash includes: 'poky/*', name: trg+'_poky', useDefaultExcludes: false | ||
34 | } | 65 | } |
35 | } | 66 | } |
67 | def buildImageMap = [:] | ||
68 | for (image in images_to_buid){ | ||
69 | def imageId = image+'_build' | ||
70 | buildImageMap[imageId] = imageBuild(imageId) | ||
71 | } | ||
72 | parallel buildImageMap | ||
36 | } | 73 | } |
37 | } | 74 | } |
38 | 75 | ||
76 | =====ENVIRONMENT SETUP===== | ||
77 | |||
39 | /* | 78 | /* |
40 | Defining the first stage of the pipeline. | 79 | Defining the first stage of the pipeline. |
41 | This stage prepares the workspace and the build environment, clones ELTF scripts and | 80 | This stage prepares the workspace and the build environment, clones ELTF scripts and |
@@ -73,22 +112,46 @@ node { | |||
73 | 112 | ||
74 | // Parse directory structure in order to determine the target list | 113 | // Parse directory structure in order to determine the target list |
75 | targetList = getTargets() | 114 | targetList = getTargets() |
76 | for (item in targetList) {print item} | 115 | |
116 | // Determine needed information like the EL Profile or the release layer to be used later as environment variables | ||
117 | profile = getProfile() | ||
118 | releaseLayer = getReleaseLayer() | ||
119 | buildStamp = BUILD_ID | ||
120 | print profile | ||
121 | print releaseLayer | ||
122 | print buildStamp | ||
123 | |||
77 | 124 | ||
78 | print 'Finished stage Environment Setup' | 125 | print 'Finished stage Environment Setup' |
79 | } | 126 | } |
80 | 127 | ||
128 | =====BUILD===== | ||
129 | |||
130 | /* | ||
131 | Defining the seond stage of the pipeline, the Build stege | ||
132 | This stage defines the threads to be run in parallel for each target, based on | ||
133 | the list of targets identified in previous stage. It then runs each thread in | ||
134 | parallel. The steps in each thread are defined in the closure retuned by the | ||
135 | targetBuild function. When all parallel threads are finished, a message is | ||
136 | printed on the console. | ||
137 | */ | ||
138 | |||
81 | stage 'Build' | 139 | stage 'Build' |
82 | // Create the build map which defines the build threads | 140 | // Create the build map which defines the build threads |
83 | def buildMap = [:] | 141 | def buildTargetMap = [:] |
84 | for (item in targetList){ | 142 | for (item in targetList){ |
85 | def id = item+'_build' | 143 | def id = item+'_build' |
86 | buildMap[id] = targetBuild(item) | 144 | buildTargetMap[id] = targetBuild(item) |
87 | } | 145 | } |
88 | parallel buildMap | 146 | // Run threads for each target in parallel |
147 | parallel buildTargetMap | ||
148 | |||
89 | node { | 149 | node { |
90 | print 'Finished stage Build' | 150 | print 'Finished stage Build' |
91 | } | 151 | } |
152 | |||
153 | =====TEST===== | ||
154 | |||
92 | stage 'Test' | 155 | stage 'Test' |
93 | node { | 156 | node { |
94 | print 'Finished stage Test' | 157 | print 'Finished stage Test' |