Listing 1. basic-mock-jenkins.sh11690l1.qrk
#!/bin/bash -xe
# keep in mind DIST is defined in multi-configuration axis
MOCK="/usr/bin/mock -r $DIST"
PKG=${JOB_NAME##*/}
# keep in mind VER could also be a multi-configuration axis
VER=${VER:-1.0}
# if you are ripping apart an RPM might have this one too
REL=${REL:-4.el6}
OUT=$PWD/output
wget -O $PKG-$VER.tar.gz http://www.example.com/sources/$PKG-$VER.tar.gz
rm -f $OUT/*.src.rpm
if ! $MOCK --resultdir=$OUT --buildsrpm --spec=$PKG.spec --sources=$PWD
then
more $OUT/*.log | cat
exit -1
fi
if ! $MOCK --resultdir=$OUT --rebuild $OUT/*.src.rpm
then
more $OUT/*.log | cat
exit -1
fi
rpmlint $OUT/*.rpm > rpmlint.log