jobs/gerrit-binpkgs: new job for deb, rpm packages

Build deb and rpm packages for each patch submitted to gerrit for the
projects in the list.

Example:
https://gerrit.osmocom.org/c/osmo-bsc-nat/+/29492

Related: OS#2385
Change-Id: I7ca8869c2e9f2e7c74a360933be12b5c2b47c2fc
This commit is contained in:
Oliver Smith 2022-10-07 15:39:38 +02:00
parent 7614916a72
commit 9e1f9ae039
2 changed files with 205 additions and 9 deletions

118
jobs/gerrit-binpkgs.yml Normal file
View File

@ -0,0 +1,118 @@
# This file holds all gerrit verifications for building deb and rpm packages.
# https://jenkins.osmocom.org/jenkins/view/Jenkins-Gerrit/.
# One can simply add a gerrit job by adding project's repository to repos list.
- project:
name: gerrit-binpkgs
jobs:
- 'gerrit-binpkgs-{type}'
type:
- 'deb'
- 'rpm'
- job-template:
name: 'gerrit-binpkgs-{type}'
project-type: freestyle
node: osmocom-gerrit-debian10 || osmocom-gerrit-debian11
concurrent: true
retry-count: 3 # scm checkout
properties:
- build-discarder:
days-to-keep: 30
num-to-keep: 120
artifact-days-to-keep: -1
artifact-num-to-keep: -1
description: |
{type} package job of CI for patches sent to
<a href="https://gerrit.osmocom.org">gerrit</a>
</br></br>
Related issue: <a href="https://osmocom.org/issues/2385">OS#2385</a>
parameters:
- string:
name: BRANCH_CI
description: |
osmo-ci.git branch
default: 'origin/master'
- string:
name: GERRIT_REPO_URL
description: set by gerrit verification pipeline job
- string:
name: GERRIT_BRANCH
description: set by gerrit verification pipeline job
- string:
name: GERRIT_REFSPEC
description: set by gerrit verification pipeline job
- string:
name: PROJECT_NAME
description: project to test, e.g. 'libosmocore' (set by pipeline)
scm:
- git:
basedir: 'code-from-gerrit'
url: '$GERRIT_REPO_URL'
credentials-id: d5eda5e9-b59d-44ba-88d2-43473cb6e42d
branches:
- $GERRIT_BRANCH
refspec: $GERRIT_REFSPEC
name:
choosing-strategy: gerrit
wipe-workspace: true
skip-tag: true
submodule:
recursive: false
- git:
basedir: 'osmo-ci'
url: 'https://gerrit.osmocom.org/osmo-ci'
credentials-id: d5eda5e9-b59d-44ba-88d2-43473cb6e42d
branches:
- '$BRANCH_CI'
wipe-workspace: true
builders:
- shell: |-
# Skip rpm build if .spec.in file is missing
if [ "{type}" = "rpm" ] && [ -z "$(find code-from-gerrit -name '*.spec.in')" ]; then
set +x
echo
echo "No *.spec.in file found, skipping rpm build."
echo
exit 0
fi
# Get distro from type
case "{type}" in
deb) distro="debian:11" ;;
rpm) distro="almalinux:8" ;;
*) echo "unknown package format: '{type}'"; exit 1 ;;
esac
# Move code from gerrit to build_srcpkg.py's git cache
cache_dir=osmo-ci/scripts/obs/_cache
mkdir -p $cache_dir
mv code-from-gerrit "$cache_dir/$PROJECT_NAME"
# Set a known branch name
git -C "$cache_dir/$PROJECT_NAME" checkout -B "origin/gerrit"
# Build source package
cd osmo-ci/scripts/obs/
./build_srcpkg.py \
--docker \
--feed master \
--git-branch gerrit \
--git-skip-fetch \
"$PROJECT_NAME"
# Build binary package
./build_binpkg.py \
--docker "$distro" \
"$PROJECT_NAME"
wrappers:
- ansicolor:
colormap: xterm
- ssh-agent-credentials:
users:
- d5eda5e9-b59d-44ba-88d2-43473cb6e42d
# vim: expandtab tabstop=2 shiftwidth=2

View File

@ -67,14 +67,18 @@
# Which jobs to run in the pipeline
pipeline_build: true
pipeline_lint: true
pipeline_binpkgs: true
# in alphabetical order
repos:
- asn1c
- asn1c:
pipeline_binpkgs: false
- cellmgr-ng
- docker-playground:
pipeline_build: false
pipeline_binpkgs: false
- libasn1c
- libgtpnl
@ -91,7 +95,10 @@
cmd: '{docker_run} {docker_img} {timeout_cmd} /build/contrib/jenkins_arch.sh "$arch"'
- libsmpp34
- libtelnet
- libtelnet:
pipeline_binpkgs: false
- libusrp
- openbsc:
@ -152,6 +159,7 @@
- osmo-e1-hardware:
docker_img: 'registry.osmocom.org/$USER/fpga-build'
cmd: 'docker pull {docker_img} && {docker_run} {docker_img} {timeout_cmd} /build/contrib/jenkins.sh'
pipeline_binpkgs: false
- osmo-ggsn:
a1_name: GTP
@ -173,6 +181,7 @@
repos_url: '{gerrit_url}/erlang/{repos}'
gerrit_project: 'erlang/{repos}'
cmd: '{docker_run} {docker_img_erlang} {timeout_cmd} /build/contrib/jenkins.sh'
pipeline_binpkgs: false
- osmo-hlr
- osmo-iuh
@ -242,6 +251,7 @@
repos_url: '{gerrit_url}/erlang/{repos}'
gerrit_project: 'erlang/{repos}'
cmd: '{docker_run} {docker_img_erlang} {timeout_cmd} /build/contrib/jenkins.sh'
pipeline_binpkgs: false
- osmo-sip-connector
@ -262,22 +272,41 @@
-e WITH_MANUALS="$WITH_MANUALS" \
{docker_img} {timeout_cmd} /build/contrib/jenkins.sh
- osmocom-bb
- osmo-tetra
- osmocom-bb:
pipeline_binpkgs: false
- osmo-tetra:
pipeline_binpkgs: false
- osmo-sysmon
- osmo-remsim
- simtrace2
- osmo-opencm3-projects:
docker_img: '$USER/debian-bullseye-jenkins'
cmd: '{docker_run} {docker_img} {timeout_cmd} /build/contrib/jenkins.sh'
- osmo-asf4-dfu
- osmo-ccid-firmware
pipeline_binpkgs: false
- osmo-asf4-dfu:
pipeline_binpkgs: false
- osmo-ccid-firmware:
pipeline_binpkgs: false
- osmo-e1d
- osmo-cbc
- osmo-e1-recorder
- gapk
- osmo-e1-recorder:
pipeline_binpkgs: false
- gapk:
pipeline_binpkgs: false
- osmo-uecups
- osmo-el2tpd
- osmo-el2tpd:
pipeline_binpkgs: false
- osmo-smlc
- osmo-gbproxy
- osmo-hnodeb
@ -288,6 +317,7 @@
slave_axis: !!python/tuple [simtester]
concurrent: false
cmd: '{timeout_cmd} ./contrib/jenkins.sh'
pipeline_binpkgs: false
- osmo-ttcn3-hacks:
slave_axis: !!python/tuple [ttcn3]
@ -304,9 +334,11 @@
su build -c 'make clean';
su build -c 'make compile';
"
pipeline_binpkgs: false
- dahdi-tools:
pipeline_lint: false
pipeline_binpkgs: false
jobs:
- 'gerrit-{repos}'
@ -328,6 +360,10 @@
name: REPO_URL
description: Clone URL, to be passed to jobs started in the pipeline
default: '{obj:repos_url}'
- bool:
name: PIPELINE_BINPKGS
description: Enable the binpkgs job (build deb/rpm packages)
default: '{obj:pipeline_binpkgs}'
dsl: |
pipeline {{
agent {{ label "osmocom-gerrit" }}
@ -374,12 +410,54 @@
}}
}}
}}
stage("deb") {{
when {{
expression {{ params.PIPELINE_BINPKGS }}
}}
steps {{
script {{
// Run the binpkgs job for this repository and keep going on failure
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {{
env.PIPELINE_DEB_PASSED = "0"
build job: 'gerrit-binpkgs-deb', parameters: [
string(name: "GERRIT_BRANCH", value: "${{env.GERRIT_BRANCH}}"),
string(name: "GERRIT_REFSPEC", value: "${{env.GERRIT_REFSPEC}}"),
string(name: "GERRIT_REPO_URL", value: "${{env.REPO_URL}}"),
string(name: "PROJECT_NAME", value: "{repos}"),
]
env.PIPELINE_DEB_PASSED = "1"
}}
}}
}}
}}
stage("rpm") {{
when {{
expression {{ params.PIPELINE_BINPKGS }}
}}
steps {{
script {{
// Run the binpkgs job for this repository and keep going on failure
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {{
env.PIPELINE_RPM_PASSED = "0"
build job: 'gerrit-binpkgs-rpm', parameters: [
string(name: "GERRIT_BRANCH", value: "${{env.GERRIT_BRANCH}}"),
string(name: "GERRIT_REFSPEC", value: "${{env.GERRIT_REFSPEC}}"),
string(name: "GERRIT_REPO_URL", value: "${{env.REPO_URL}}"),
string(name: "PROJECT_NAME", value: "{repos}"),
]
env.PIPELINE_RPM_PASSED = "1"
}}
}}
}}
}}
}}
}}
stage("Result") {{
steps {{
echo "PIPELINE_BUILD_PASSED=${{env.PIPELINE_BUILD_PASSED}}"
echo "PIPELINE_LINT_PASSED=${{env.PIPELINE_LINT_PASSED}}"
echo "PIPELINE_DEB_PASSED=${{env.PIPELINE_DEB_PASSED}}"
echo "PIPELINE_RPM_PASSED=${{env.PIPELINE_RPM_PASSED}}"
}}
}}
// The end result is success if all started jobs were successful,