summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Gheorghiu <adgh@eltf-jenkins02.stolab01.enea.se>2016-09-15 10:16:29 +0200
committerAndrei Gheorghiu <adgh@eltf-jenkins02.stolab01.enea.se>2016-09-15 10:16:29 +0200
commit32ca93c38b4c949ddfdd518ad81ca2caabb30f1d (patch)
treeab8d2606d89d53c834d102c5db7b656906b63605
parent4dabcec0cc83da1a0d3031b94831cee764a15d5b (diff)
downloadel_manifests-standard-32ca93c38b4c949ddfdd518ad81ca2caabb30f1d.tar.gz
updated Jenkinsfile
-rw-r--r--Jenkinsfile196
1 files changed, 15 insertions, 181 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index 971a250..e8beaac 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,184 +1,18 @@
1import groovy.io.FileType 1#!/bin/env groovy
2//=====USER DEFINED VARIABLES===== 2
3def images_to_buid = ['enea-image-'+profile, 'enea-image-'+profile+'-sdk', 'world'] 3stage "Loading Sripts"
4def localGitRoot = 'http://git.enea.se/cgit/various/' 4
5def publicGitRoot = 'http://git.enea.com/cgit/linux/' 5node ('master') {
6 6 print 'master node'
7//=====USER DEFINED FUNCTIONS===== 7 dir ("../${env.BRANCH_NAME}@script") {
8 8 def git_remote_url = sh returnStdout: true, script: "git remote get-url origin"
9def getProfile(){ 9 def git_repo = git_remote_url.trim().split('/')[-1]
10 return 'standard' 10 def git_repo_name = git_repo.replace('.git','')
11} 11 def profile = git_repo_name.split('-')[-1]
12 12 env.PROFILE = profile
13def getReleaseLayer(){ 13 sh 'echo $PROFILE'
14 releaseLayer = 'meta-el-'+getProfile()
15 return releaseLayer
16}
17
18@NonCPS def getTargets(){
19 targetList = []
20 dirList = new File(pwd()+'/manifest_repo/.repo/manifests/')
21 dirList.eachFile { file -> if (file.directory && file.name!='.git' && file.name!='common'){targetList.add file.name}}
22 return targetList
23}
24
25def imageBuild(imageType, machine, profile, buildStamp, releaseLayer){
26 {
27 it-> node{
28 print 'Starting build for each image type '+imageType
29 print machine
30 print profile
31 print buildStamp
32 print releaseLayer
33 print pwd()
34 dir (trg){
35 unstash machine+'_poky'
36 }
37 }
38 }
39}
40
41def targetBuild(trg, images_to_buid, profile, buildStamp, releaseLayer){
42 {
43 target=trg-> node{
44 //sh 'mkdir ${trg}'
45 dir (trg){
46 unstash 'eltf_scripts'
47 checkout([$class: 'RepoScm',
48 currentBranch: true,
49 manifestBranch: '$BRANCH_NAME',
50 manifestFile: trg+'/default.xml',
51 //The hardcoded repository should be replaced by a generic name, eg. $GIT_PATH+el_manifests-$PROFILE
52 manifestRepositoryUrl: 'http://git.enea.se/cgit/various/el_manifests-standard.git',
53 quiet: true,
54 showAllChanges: true,
55 trace: true])
56 print 'Finished cloning with Repo tool'
57 checkout([$class: 'GitSCM',
58 branches: [[name: '$BRANCH_NAME']],
59 doGenerateSubmoduleConfigurations: false,
60 extensions: [[$class: 'RelativeTargetDirectory',
61 relativeTargetDir: 'poky/'],
62 [$class: 'AuthorInChangelog']],
63 submoduleCfg: [],
64 userRemoteConfigs: [[credentialsId: 'a797f854-983e-473e-b221-6d8ebafda16a',
65 url: 'git@git.enea.se:linux/meta-enea-test.git']]])
66 print 'Finished cloing meta-enea-test'
67 print pwd()
68 dir (poky){
69 stash trg+'_poky'
70 }
71 }
72 } 14 }
73 def buildImageMap = [:]
74 for (image in images_to_buid){
75 def imageId = 'build_'+image+'_for_'+trg
76 buildImageMap[imageId] = imageBuild(imageId, trg, profile, buildStamp, releaseLayer)
77 }
78 parallel buildImageMap
79 }
80}
81
82//=====ENVIRONMENT SETUP=====
83
84/*
85Defining the first stage of the pipeline.
86This stage prepares the workspace and the build environment, clones ELTF scripts and
87stashes them in order to be used on all distrubuted nodes.
88This stage is also determining needed information like the targets to be built/tested.
89*/
90
91stage 'Environment Setup'
92node {
93 // Delete workspace content before running any step
94 deleteDir()
95
96 // Freeze manifest files before running builds
97 print "To add a job to freeze the manifest repositories"
98
99 // Clone eltf/scripts.git repository
100 checkout([$class: 'GitSCM',
101 branches: [[name: '*/master']],
102 doGenerateSubmoduleConfigurations: false,
103 extensions: [[$class: 'RelativeTargetDirectory',relativeTargetDir: 'eltf_scripts']],
104 submoduleCfg: [],
105 userRemoteConfigs: [[url: 'git@git.enea.se:eltf/scripts.git']]])
106
107 // Stash the ELTF scripts in order to be used on other nodes
108 stash includes: 'eltf_scripts/*', name: 'eltf_scripts', useDefaultExcludes: false
109
110 // Clone manifest repository in order to determine target list
111 checkout([$class: 'RepoScm',
112 currentBranch: true,
113 destinationDir: 'manifest_repo',
114 manifestBranch: 'master',
115 manifestRepositoryUrl: 'http://git.enea.se/cgit/various/el_manifests-standard.git',
116 showAllChanges: true,
117 trace: true])
118
119 // Parse directory structure in order to determine the target list
120 targetList = getTargets()
121
122 // Determine needed information like the EL Profile or the release layer to be used later as environment variables
123 profile = getProfile()
124 releaseLayer = getReleaseLayer()
125 buildStamp = env.BUILD_TIMESTAMP
126 print profile
127 print releaseLayer
128 print buildStamp
129
130
131 print 'Finished stage Environment Setup'
132}
133
134//=====BUILD=====
135
136/*
137Defining the seond stage of the pipeline, the Build stege
138This stage defines the threads to be run in parallel for each target, based on
139the list of targets identified in previous stage. It then runs each thread in
140parallel. The steps in each thread are defined in the closure retuned by the
141targetBuild function. When all parallel threads are finished, a message is
142printed on the console.
143*/
144
145stage 'Build'
146// Create the build map which defines the build threads
147def buildTargetMap = [:]
148for (item in targetList){
149 def id = item+'_build'
150 buildTargetMap[id] = targetBuild(item, images_to_buid, profile, buildStamp, releaseLayer)
151}
152// Run threads for each target in parallel
153parallel buildTargetMap
154
155node {
156 print 'Finished stage Build'
157}
158
159//=====TEST=====
160
161stage 'Test'
162node {
163 print 'Finished stage Test'
164}
165stage 'Document'
166node {
167 print 'Finished stage Document'
168}
169stage 'Build Documentation'
170node {
171 print 'Finished stage Build Documentation'
172}
173stage 'Build Release Candidate'
174node {
175 print 'Finished stage Build RC'
176}
177stage 'Publish Release Candidate'
178node {
179 print 'Finished stage Publish RC'
180} 15}
181stage 'Publish official Release' 16fileLoader.withGit('git@git.enea.se:eltf/jenkins.git', 'master', null, '') {
182node { 17 fileLoader.load('el_pipeline.groovy');
183 print 'Finished stage Publish Release'
184} 18}