I let jenkins build rpm with post-install scriptlets that perform several tasks during install. One of those may fail and send an error like
warning: %post(test-1-1.noarch) scriptlet failed, exit status 1
Unfortunately this seems not to result in a proper exit status from the rpm call.
# echo $?
0
Actually I need the rpm install send an exit state >0
Is there some hidden rpm option that I am missing or is there something missing in my scriptlet?
This is how my scriptlets look like (created by effing package manager via jenkins with variables <%= installPath %>, <%= webUser %> inserted during creation)
#!/usr/bin/env bash
INSTALLPATH=<%= installPath %>
WEBUSER=<%= webUser %>
HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
mkdir -p $INSTALLPATH/app/cache
setfacl -R -m u:"$HTTPDUSER":rwX -m u:"$WEBUSER":rwX $INSTALLPATH/app/cache
setfacl -dR -m u:"$HTTPDUSER":rwX -m u:"$WEBUSER":rwX $INSTALLPATH/app/cache
mkdir -p $INSTALLPATH/app/logs
setfacl -R -m u:"$HTTPDUSER":rwX -m u:"$WEBUSER":rwX $INSTALLPATH/app/logs
setfacl -dR -m u:"$HTTPDUSER":rwX -m u:"$WEBUSER":rwX $INSTALLPATH/app/logs
mkdir -p $INSTALLPATH/web/cache
setfacl -R -m u:"$HTTPDUSER":rwX -m u:"$WEBUSER":rwX $INSTALLPATH/web/cache
setfacl -dR -m u:"$HTTPDUSER":rwX -m u:"$WEBUSER":rwX $INSTALLPATH/web/cache
sudo su $WEBUSER -c "php $INSTALLPATH/vendor/sensio/distribution-bundle/Resources/bin/build_bootstrap.php"
sudo su $WEBUSER -c "php $INSTALLPATH/app/console cache:warmup"
sudo su $WEBUSER -c "php $INSTALLPATH/app/console assets:install $INSTALLPATH/web"
sudo su $WEBUSER -c "php $INSTALLPATH/app/console doctrine:database:drop --if-exists --no-interaction --force"
sudo su $WEBUSER -c "php $INSTALLPATH/app/console doctrine:database:create --if-not-exists"
sudo su $WEBUSER -c "php $INSTALLPATH/app/console doctrine:schema:create"
The rpm install is called by
#!/bin/sh
#
# allows jenkins to install rpm as privileged user
#
# add the following line to /etc/sudoers:
# jenkins ALL = NOPASSWD: /usr/local/sbin/jenkins-rpm-install
#
artifact=$1
rpm -vv --install --force $artifact
err_code=$?
if [[ err_code > 0 ]]; then exit 1; fi
Any recommendations are welcome.
(This question is a follow up from jenkins shall fail on errors during rpm install job)