blob: b874aa2672468a8b67635fe2f04d3195b20fba5d (
plain)
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
116
117
|
#!/usr/bin/env groovy
def RPMSource() {
dir ('source') {
checkout([
$class: 'GitSCM',
branches: [
[ name: '*/master' ]
],
extensions: [
[
$class: 'CloneOption',
timeout: 60
]
],
userRemoteConfigs: [
[ url: 'http://git.ipxe.org/ipxe.git' ]
]])
}
}
def RPMBuild() {
sh '''
# figure version
commit="$(cd source; git describe --tags --long --match 'v*')"
ghash="${commit##*-}"
commit="${commit%-*}"
gcnt="${commit##*-}"
commit="${commit%-*}"
version="${commit#v}"
# fresh snapshot tarball
rm -f *.tar.gz
tarball="ipxe-${ghash}.tar.gz"
(cd source; git archive --format=tar --prefix="${tarball%.tar.gz}/" HEAD) \
| gzip > "${tarball}"
# tweak spec file
sed -i.orig \
-e "s/\\(Version:[ \\t]\\+\\)\\(.*\\)/\\1${version}/" \
-e "s/\\(Release:[ \\t]\\+\\)\\(.*\\)/\\1${gcnt}.${BUILD_NUMBER}.${ghash}/" \
-e "s/\\(Source0:[ \\t]\\+\\)\\(.*\\)/\\1${tarball}/" \
-e "s/\\(%setup\\)\\(.*\\)/\\1 -n ${tarball%.tar.gz}/" \
*.spec
diff -u *.spec.orig *.spec || true
# install deps
/usr/local/bin/configure-mirror
yum-builddep -y *.spec
# build package
rpmbuild \
--define "_specdir ${WORKSPACE}" \
--define "_sourcedir ${WORKSPACE}" \
--define "_rpmdir ${WORKSPACE}/rpms" \
--define "_srcrpmdir ${WORKSPACE}/rpms/src" \
--define "_builddir ${WORKSPACE}/build" \
--define "_buildrootdir ${WORKSPACE}/buildroot" \
-ba *.spec
# revert spec file tweaks
git reset --hard
# drop source rpm
rm -rf "${WORKSPACE}/rpms/src"
# create rpm package repo
createrepo_c rpms
'''
archiveArtifacts 'rpms/*/*'
}
pipeline {
agent {
kubernetes {
yamlFile 'centos7-rpmbuild.yaml'
defaultContainer 'centos7-rpmbuild'
slaveConnectTimeout '3600'
nodeSelector 'kubernetes.io/os=linux,kubernetes.io/arch=amd64'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
disableConcurrentBuilds()
}
triggers {
pollSCM('H * * * *')
}
stages {
stage ('Prepare') {
steps {
RPMSource();
}
}
stage ("RPM Build") {
steps {
RPMBuild()
}
}
}
post {
failure {
emailext([
to: 'builds@kraxel.org',
subject: "${JOB_NAME} - build #${BUILD_NUMBER} - FAILED!",
body: "${BUILD_URL}\n",
attachLog: true,
])
}
}
}
|