-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
115 lines (89 loc) · 2.48 KB
/
Jenkinsfile
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
103
104
105
106
107
108
109
110
111
112
113
114
115
@Library('conservify') _
properties([
disableConcurrentBuilds(),
[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '20']]
])
def uploadFirmware(Map parameters = [:]) {
def command = "--scheme https"
if (parameters.directory) {
command += " --firmware-directory " + parameters.directory
}
if (parameters.file) {
command += " --firmware-file " + parameters.file
}
if (parameters.module) {
command += " --module " + parameters.module
}
if (parameters.profile) {
command += " --profile " + parameters.profile
}
if (parameters.email) {
command += " --email " + parameters.email
}
if (parameters.password) {
command += " --password " + parameters.password
}
if (parameters.version) {
command += " --version " + parameters.version
}
def dev = "third-party/fktool --host api.fkdev.org " + command
echo dev
sh dev
def prod = "third-party/fktool --host api.fieldkit.org " + command
echo prod
sh prod
}
def getBranch(scmInfo) {
def (remoteOrBranch, branch) = scmInfo.GIT_BRANCH.tokenize('/')
if (branch) {
return branch;
}
return remoteOrBranch;
}
timestamps {
node ("jenkins-aws-ubuntu") {
try {
def scmInfo
stage ('git') {
scmInfo = checkout scm
}
def branch = getBranch(scmInfo)
notifyStarted()
stage ('build') {
sh "env"
sh "make veryclean"
withEnv(["GIT_LOCAL_BRANCH=${branch}"]) {
withEnv(["PATH+GOLANG=${tool 'golang-amd64'}/bin"]) {
withEnv(["PATH+GOHOME=${HOME}/go/bin"]) {
withPythonEnv("python3") {
sh "which python3"
sh "which python"
sh "make ci"
}
}
}
}
}
stage ('test') {
sh "make test"
}
def version = readFile('build/samd51/version.txt')
currentBuild.description = version.trim()
stage ('archive') {
archiveArtifacts artifacts: "build/*.zip, build/*/*.zip"
}
stage ('distribute') {
withCredentials([usernamePassword(credentialsId: 'fkpassword', usernameVariable: 'FK_USER', passwordVariable: 'FK_PASSWORD')]) {
uploadFirmware(version: version, profile: 'standard', module: 'fk-core', file: "build/samd51/fk/fk-bundled-fkb.bin", email: "${env.FK_USER}", password: "${env.FK_PASSWORD}")
uploadFirmware(version: version, profile: 'standard', module: 'fk-bl', file: "build/samd51/bootloader/fkbl-fkb.bin", email: "${env.FK_USER}", password: "${env.FK_PASSWORD}")
}
}
refreshDistribution()
notifySuccess()
}
catch (Exception e) {
notifyFailure()
throw e;
}
}
}