forked from ayufan-rock64/linux-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
102 lines (93 loc) · 2.33 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
pipeline {
// parameters {
// string (
// defaultValue: '1.0',
// description: 'Current version number',
// name : 'VERSION')
// text (
// defaultValue: '',
// description: 'A list of changes',
// name : 'CHANGES')
// booleanParam (
// defaultValue: false,
// description: 'If build should be marked as pre-release',
// name : 'PRERELEASE')
// string (
// defaultValue: '1.0',
// description: 'GitHub username or organization',
// name : 'GITHUB_USER')
// string (
// defaultValue: '1.0',
// description: 'GitHub repository',
// name : 'GITHUB_REPO')
// }
agent {
dockerfile {
dir 'build-environment'
label 'docker && linux-build'
args '--privileged -u 0:0'
}
}
environment {
USE_CCACHE = 'true'
RELEASE_NAME = "$RELEASE_NAME"
RELEASE = "$BUILD_NUMBER"
CCACHE_DIR = "$WORKSPACE/ccache"
PRERELEASE = "$PRERELEASE"
GITHUB_USER = "$GITHUB_USER"
GITHUB_REPO = "$GITHUB_REPO"
}
options {
timestamps()
}
stages {
stage('Prepare') {
steps {
sh 'ccache -M 0 -F 0'
sh 'git clean -ffdx -e ccache'
}
}
stage('Build') {
steps {
sh 'make'
}
}
stage('Release') {
steps {
sh '''#!/bin/bash
set -xe
shopt -s nullglob
github-release release \
--tag "${VERSION}" \
--name "$VERSION: $BUILD_TAG" \
--description "${CHANGES}\n\n${BUILD_URL}" \
--draft
for file in *.xz *.deb; do
github-release upload \
--tag "${VERSION}" \
--name "$(basename "$file")" \
--file "$file" &
done
wait
if [[ "$PRERELEASE" == "true" ]]; then
github-release edit \
--tag "${VERSION}" \
--name "$VERSION: $BUILD_TAG" \
--description "${CHANGES}\n\n${BUILD_URL}" \
--pre-release
else
github-release edit \
--tag "${VERSION}" \
--name "$VERSION: $BUILD_TAG" \
--description "${CHANGES}\n\n${BUILD_URL}"
fi
'''
}
}
}
post {
always {
sh 'git clean -ffdx -e ccache'
}
}
}