-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Jenkinsfile
95 lines (93 loc) · 4.79 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
pipeline {
agent any
parameters {
string(name: 'BASE_VERSION', defaultValue: '1.1', description: 'From https://github.com/dernasherbrezon/sdr-server/actions')
string(name: 'BUILD_NUMBER', defaultValue: '77', description: 'From https://github.com/dernasherbrezon/sdr-server/actions')
choice(name: 'DOCKER_IMAGE', choices: ['debian:stretch-slim', 'debian:buster-slim', 'debian:bullseye-slim', 'debian:bookworm-slim', 'ubuntu:jammy', 'ubuntu:bionic', 'ubuntu:focal'], description: 'From https://github.com/dernasherbrezon/sdr-server/actions')
choice(name: 'OS_ARCHITECTURE', choices: ['armhf', 'arm64', 'amd64'], description: 'From https://github.com/dernasherbrezon/sdr-server/actions')
}
stages {
stage('Checkout') {
steps {
script {
env.OS_CODENAME = "${DOCKER_IMAGE}".split(':')[1].split('-')[0]
}
git(url: 'git@github.com:dernasherbrezon/sdr-server.git', branch: "${OS_CODENAME}", credentialsId: 'github', changelog: false)
sh '''
git config user.email "gpg@r2cloud.ru"
git config user.name "r2cloud"
git merge origin/main --no-edit
'''
withCredentials([sshUserPrivateKey(credentialsId: 'github', keyFileVariable: 'SSH_KEY')]) {
sh '''
GIT_SSH_COMMAND="ssh -i ${SSH_KEY}" git push --set-upstream origin ${OS_CODENAME}
'''
}
}
}
stage('build') {
agent {
docker {
image "sdrserver-${OS_CODENAME}-${OS_ARCHITECTURE}"
reuseNode true
args "--platform=linux/${OS_ARCHITECTURE}"
}
}
steps {
sh '''#!/bin/bash
set -e
. ./configure_flags.sh nocpuspecific
rm -rf build
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCPACK_DEBIAN_PACKAGE_VERSION=${BASE_VERSION}.${BUILD_NUMBER}~${OS_CODENAME} -DCUSTOM_ARCHITECTURE=${OS_ARCHITECTURE} ..
VERBOSE=1 make -j $(nproc)
cpack
'''
}
}
stage('deploy') {
steps {
withCredentials([
usernamePassword(credentialsId: 'gpg_pass', usernameVariable: 'gpg_pass_keyid', passwordVariable: 'gpg_pass'),
file(credentialsId: 'gpg', variable: 'gpg_file'),
file(credentialsId: 'gpg_passphrase', variable: 'gpg_passphrase'),
aws(credentialsId: 'aws')]) {
sh '''#!/bin/bash
set -e
. ./configure_flags.sh nocpuspecific
APT_CLI_VERSION="apt-cli-1.11"
if [ ! -f ${HOME}/${APT_CLI_VERSION}.jar ]; then
wget -O ${APT_CLI_VERSION}.jar.temp https://github.com/dernasherbrezon/apt-cli/releases/download/${APT_CLI_VERSION}/apt-cli.jar
mv ${APT_CLI_VERSION}.jar.temp ${HOME}/${APT_CLI_VERSION}.jar
fi
java -jar ${HOME}/${APT_CLI_VERSION}.jar --url s3://${BUCKET} --component main --codename ${OS_CODENAME} --gpg-keyfile ${gpg_file} --gpg-keyname ${gpg_pass_keyid} --gpg-passphrase-file ${gpg_passphrase} save --patterns ./build/*.deb,./build/*.ddeb
'''
}
}
}
stage('test') {
agent {
docker {
image "${DOCKER_IMAGE}"
reuseNode true
args "--platform=linux/${OS_ARCHITECTURE} --pull always --user root"
}
}
steps {
sh '''#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
cp ./docker/r2cloud.gpg /etc/apt/trusted.gpg.d/r2cloud.gpg
chmod 644 /etc/apt/trusted.gpg.d/r2cloud.gpg
if [ ${OS_CODENAME} == stretch ]; then
echo 'deb http://archive.debian.org/debian/ stretch main non-free contrib' > /etc/apt/sources.list
echo 'deb http://archive.debian.org/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list
fi
echo "deb http://r2cloud.s3.amazonaws.com ${OS_CODENAME} main" >> /etc/apt/sources.list
echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic ${OS_CODENAME} main" >> /etc/apt/sources.list
apt update && apt-get install --no-install-recommends -y sdr-server
'''
}
}
}
}