-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
50 lines (49 loc) · 1.66 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
#! groovy
node ('docker') {
properties([
parameters([
booleanParam(
defaultValue: false,
description: 'publish to apt repos',
name: 'publish'
)
])
])
dir ("${WORKSPACE}/build") {
sh "install -d ${WORKSPACE}/build";
stage ('Fetch repository') {
git credentialsId: '9518243f-f5dd-4054-8420-d5da92a6da1e', url: 'git@github.com:BrandwatchLtd/trunkfingerprint.git';
}
stage ('Build Docker image') {
img = docker.build('debian9-pgsql-builder');
}
}
stage ('Build debian packages') {
sh "docker run -v $WORKSPACE:/mnt --rm ${img.id} dpkg-buildpackage -b";
sh "ls ${WORKSPACE}; ls ${WORKSPACE}/";
}
dir ("${WORKSPACE}")
{
stage ('Upload to repositories') {
if (params.publish) {
[
'http://apt.service0.btn1.bwcom.net/publish'
].each { aptly_uploader_url ->
withCredentials([usernameColonPassword(credentialsId: 'aptly-uploader', variable: 'USERPASS')]) {
sh """
for deb in postgresql-trunkfingerprint*.deb; do
# \$ for substitution to perform on Bash side, not in Groovy
curl --max-redirs 0 -f -u "${USERPASS}" "${aptly_uploader_url}" -F "file=@\${deb}" -F "name=\${deb}"
done
"""
}
}
} else {
print 'skipping publish step'
}
}
stage ('Cleanup') {
cleanWs();
}
}
}