-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJenkinsfile
More file actions
103 lines (94 loc) · 3.63 KB
/
Copy pathJenkinsfile
File metadata and controls
103 lines (94 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env groovy
/**
* Build Creator feed packages
*
* Configure as needed, pull in the feeds and run the build.
* Overrides Creator feed with local clone.
*
*/
def creatorPackages = [
'awalwm2m',
'bit-bang-gpio',
'gcc53',
'info-daemon',
'letmecreate',
'onboarding-scripts',
'pickle',
'provisioning-daemon',
'pyletmecreate',
]
properties([
buildDiscarder(logRotator(numToKeepStr: '30')),
parameters([
stringParam(defaultValue: 'http://downloads.creatordev.io/openwrt/ci40-v1.1.1/pistachio/marduk/OpenWrt-SDK-ci40-v1.1.1-pistachio_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2',
description: 'OpenWrt SDK tarball to use', name: "SDK_TARBALL"),
])
])
node('docker && imgtec') {
def docker_image
stage('Prepare Docker container') {
docker_image = docker.image "imgtec/creator-builder:latest"
}
docker_image.inside {
stage('Prepare') {
// checkout Creator-feed to a sub directory
checkout([$class: 'GitSCM',
userRemoteConfigs: scm.userRemoteConfigs,
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
submoduleCfg: scm.submoduleCfg,
browser: scm.browser,
gitTool: scm.gitTool,
extensions: scm.extensions + [
[$class: 'CleanCheckout'],
[$class: 'PruneStaleBranch'],
[$class: "RelativeTargetDirectory", relativeTargetDir: "${WORKSPACE}/Creator-feed"],
],
])
// Download and extract Creator SDK
sh "wget -qO- ${params.SDK_TARBALL} | tar -xvj --strip-components 1"
// Enable signed package indexing
sh "echo '\nconfig SIGNED_PACKAGES\n\tbool\n\tdefault y\n' >> Config.in"
// Override Creator feed with local clone
sh "echo 'src-link creator ../Creator-feed' >> feeds.conf.default"
// Update and install all feeds
sh "cat Config.in feeds.conf.default"
sh "scripts/feeds update -a && scripts/feeds install -a"
}
stage('Build') {
// Attempt to build quickly and reliably
// TODO Issue#32: build specific package only based on PR or commit
for (item in creatorPackages) {
try {
sh "make package/${item}/compile -j4 V=s"
} catch (hudson.AbortException err) {
// TODO BUG JENKINS-28822
if(err.getMessage().contains('script returned exit code 143')) {
throw err
}
echo 'Parallel build failed, attempting to continue in single threaded mode'
try {
sh "make package/${item}/compile -j1 V=s"
} catch (exc) {
echo "Caught: ${exc}"
currentBuild.result = 'FAILURE'
}
}
}
// Add package signing key
withCredentials([
[$class: 'FileBinding', credentialsId: 'opkg-build-private-key', variable: 'PRIVATE_KEY'],
]){
sh "cp ${env.PRIVATE_KEY} key-build"
sh "make package/index -j1 V=s"
sh "rm key-build"
}
}
stage('Upload') {
// only archive Creator feed packages and signed index
archiveArtifacts 'bin/pistachio/packages/creator/*'
// clean up the workspace to save space
deleteDir()
}
}
}