Skip to content

Commit

Permalink
migrate main build to jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Jun 24, 2024
1 parent 2a34ed5 commit 51ad707
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 122 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ name: CMake
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
BASE_VERSION: "1.1"
DEBEMAIL: "[email protected]"
DEBFULLNAME: "r2cloud"

jobs:
build:
name: Build and analyze
Expand Down Expand Up @@ -50,39 +42,3 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
- name: Merge into OS-specific branches
run: |
git config user.email "[email protected]"
git config user.name "$GITHUB_ACTOR"
git tag ${{ env.BASE_VERSION }}.${{ github.run_number }}
git push origin ${{ env.BASE_VERSION }}.${{ github.run_number }}
deploy:
name: Build, package and deploy
needs: build
strategy:
matrix:
hosts: [ubuntu-20.04, ubuntu-22.04]
cpu: ["nocpuspecific"]
runs-on: ${{ matrix.hosts }}
steps:
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Set env
run: echo "OS_CODENAME=$(lsb_release --codename --short)" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: '${{ env.OS_CODENAME }}'
- name: Configure agent
run: bash ./configure_agent.sh
- name: Build and deploy
run: bash ./build_and_deploy.sh ${{ matrix.cpu }} ${{ env.OS_CODENAME }} ${{ env.BASE_VERSION }} ${{ github.run_number }} F2DCBFDCA5A70917
114 changes: 82 additions & 32 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,95 @@
pipeline {
agent none
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')
}
environment {
GPG = credentials("GPG")
DEBEMAIL = '[email protected]'
DEBFULLNAME = 'r2cloud'
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('Package and deploy') {
matrix {
axes {
axis {
name 'OS_CODENAME'
values 'bullseye', 'stretch', 'buster', 'bookworm'
}
axis {
name 'CPU'
values 'nocpuspecific'
}
stage('Checkout') {
steps {
script {
env.OS_CODENAME = "${DOCKER_IMAGE}".split(':')[1].split('-')[0]
}
agent {
label "${OS_CODENAME}"
git(url: '[email protected]:dernasherbrezon/sdr-server.git', branch: "${OS_CODENAME}", credentialsId: 'github', changelog: false)
sh '''
git config user.email "[email protected]"
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}
'''
}
stages {
stage('Checkout') {
steps {
git(url: '[email protected]:dernasherbrezon/sdr-server.git', branch: "${OS_CODENAME}", credentialsId: '5c8b3e93-0551-475c-9e54-1266242c8ff5', changelog: false)
}
}
stage('build and deploy') {
steps {
sh 'echo $GPG_PSW | /usr/lib/gnupg2/gpg-preset-passphrase -c C4646FB23638AE9010EB1F7F37A0505CF4C5B746'
sh 'echo $GPG_PSW | /usr/lib/gnupg2/gpg-preset-passphrase -c 9B66E29FF6DDAD62FA3F2570E02775B6EFAF6609'
sh "bash ./build_and_deploy.sh ${CPU} ${OS_CODENAME} ${params.BASE_VERSION} ${params.BUILD_NUMBER} ${GPG_USR}"
}
}
}
}
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
'''
}
}
}
}
25 changes: 0 additions & 25 deletions build_and_deploy.sh

This file was deleted.

17 changes: 0 additions & 17 deletions configure_agent.sh

This file was deleted.

6 changes: 6 additions & 0 deletions docker/bionic.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:bionic
ENV DEBIAN_FRONTEND noninteractive
COPY --chmod=644 r2cloud.gpg /etc/apt/trusted.gpg.d/r2cloud.gpg
RUN echo "deb http://r2cloud.s3.amazonaws.com bionic main" >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic bionic main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y build-essential file valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
6 changes: 6 additions & 0 deletions docker/bookworm.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND noninteractive
COPY --chmod=644 r2cloud.gpg /etc/apt/trusted.gpg.d/r2cloud.gpg
RUN echo "deb http://r2cloud.s3.amazonaws.com bookworm main" >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic bookworm main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y build-essential file valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
10 changes: 8 additions & 2 deletions docker/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env bash

docker build --platform=armhf -t sdrserver-buster -f buster.Dockerfile .
docker build --platform=armhf -t sdrserver-stretch -f stretch.Dockerfile .
docker buildx build --load --platform=armhf -t sdrserver-buster-armhf -f buster.Dockerfile .
docker buildx build --load --platform=armhf -t sdrserver-stretch-armhf -f stretch.Dockerfile .
docker buildx build --load --platform=armhf -t sdrserver-bullseye-armhf -f bullseye.Dockerfile .
docker buildx build --load --platform=armhf -t sdrserver-bookworm-armhf -f bookworm.Dockerfile .
docker buildx build --load --platform=arm64 -t sdrserver-bookworm-arm64 -f bookworm.Dockerfile .
docker buildx build --load --platform=amd64 -t sdrserver-bionic-amd64 -f bionic.Dockerfile .
docker buildx build --load --platform=amd64 -t sdrserver-focal-amd64 -f focal.Dockerfile .
docker buildx build --load --platform=amd64 -t sdrserver-jammy-amd64 -f jammy.Dockerfile .
6 changes: 6 additions & 0 deletions docker/bullseye.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM debian:bullseye-slim
ENV DEBIAN_FRONTEND noninteractive
COPY --chmod=644 r2cloud.gpg /etc/apt/trusted.gpg.d/r2cloud.gpg
RUN echo "deb http://r2cloud.s3.amazonaws.com bullseye main" >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic bullseye main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y build-essential file valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
2 changes: 1 addition & 1 deletion docker/buster.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ ENV DEBIAN_FRONTEND noninteractive
COPY --chmod=644 r2cloud.gpg /etc/apt/trusted.gpg.d/r2cloud.gpg
RUN echo "deb http://r2cloud.s3.amazonaws.com buster main" >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic buster main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y build-essential valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install --no-install-recommends -y build-essential file valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
6 changes: 6 additions & 0 deletions docker/focal.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:focal
ENV DEBIAN_FRONTEND noninteractive
COPY --chmod=644 r2cloud.gpg /etc/apt/trusted.gpg.d/r2cloud.gpg
RUN echo "deb http://r2cloud.s3.amazonaws.com focal main" >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic focal main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y build-essential file valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
6 changes: 6 additions & 0 deletions docker/jammy.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:jammy
ENV DEBIAN_FRONTEND noninteractive
COPY --chmod=644 r2cloud.gpg /etc/apt/trusted.gpg.d/r2cloud.gpg
RUN echo "deb http://r2cloud.s3.amazonaws.com jammy main" >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic jammy main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y build-essential file valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
2 changes: 1 addition & 1 deletion docker/stretch.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ RUN echo 'deb http://archive.debian.org/debian/ stretch main non-free contrib' >
RUN echo 'deb http://archive.debian.org/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com stretch main" >> /etc/apt/sources.list
RUN echo "deb http://r2cloud.s3.amazonaws.com/cpu-generic stretch main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y build-essential valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install --no-install-recommends -y build-essential file valgrind cmake libconfig-dev check pkg-config libvolk2-dev libvolk2-bin librtlsdr-dev zlib1g-dev && rm -rf /var/lib/apt/lists/*

0 comments on commit 51ad707

Please sign in to comment.