open-build-service
open-build-service copied to clipboard
[backend] Add buildhook feature
This PR should close #11027
For test in local environment:
- Create path buildhook:
mkdir buildhook
- Create simple buildhook script
test.sh
:#!/bin/bash BUILDROOT=$1 PROJID=$2 PACKID=$3 REPOID=$4 ARCH=$5 MODE=$6 exec > >(tee -a "$BUILDROOT/.build.log") 2>&1 if [ "$MODE" = "before" ]; then echo "Before hook executing" > $BUILDROOT/.hook.log else echo "Before hook result:" echo "-------------------" cat $BUILDROOT/.hook.log echo "-------------------" echo "After hook executing" fi
- Copy file
src/backend/BSConfig.pm.template
tosrc/backend/BSConfig.pm
and add next lines:our $buildhookpath = "/obs/buildhook"; our $beforebuildhook = {".*" => "test.sh"}; our $afterbuildhook = {".*" => "test.sh"};
- Start OBS
docker-compose up
- Add package and build it
- See build log
After
The hook would not be available for local or remote builds then. So anything, what is important for the build result would not be possible in such scripts.
So I wonder what is the use-case for this at all?
(And the mentioned API interface in the issue would actually be a root security hole).
The hook would not be available for local or remote builds then. So anything, what is important for the build result would not be possible in such scripts.
Yes it is
So I wonder what is the use-case for this at all?
As I wrote in #10853:
- Uploading results of static code analyze to the analyzer server
- Calculating special checksum of sources and binaries at build time using custom program
Additionally, using this hook, I can try to solve the problem with umount https://github.com/openSUSE/obs-build/pull/630
(And the mentioned API interface in the issue would actually be a root security hole).
Hook configuration available only for system administrator.
Yes, a bad hook can disable a worker. But this is compensated by the fact that only qualified employees have the ability to set up hooks.
Codecov Report
Merging #11177 (a9a47aa) into master (2bedc85) will increase coverage by
2.24%
. The diff coverage isn/a
.
:exclamation: Current head a9a47aa differs from pull request most recent head c4cfd08. Consider uploading reports for the commit c4cfd08 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #11177 +/- ##
==========================================
+ Coverage 88.77% 91.02% +2.24%
==========================================
Files 688 624 -64
Lines 23627 22322 -1305
==========================================
- Hits 20976 20318 -658
+ Misses 2651 2004 -647