#!/usr/bin/env groovy def RPMSource() { dir ('source') { checkout([ $class: 'GitSCM', branches: [ [ name: '*/master' ] ], extensions: [ [ $class: 'CloneOption', timeout: 60 ] ], userRemoteConfigs: [ [ url: 'git://git.seabios.org/seabios.git' ] ]]) } } def RPMBuild() { sh ''' # fresh snapshot tarball rm -f *.tar* (cd source; scripts/tarball.sh) tarball="$(cd source; ls *.tar*)" mv source/$tarball . # figure version commit="$(cd source; git describe --tags --long --match 'rel-*')" ghash="${commit##*-}" commit="${commit%-*}" gcnt="${commit##*-}" commit="${commit%-*}" version="${commit#rel-}" # tweak spec file sed -i.orig \ -e "s/(Version:[ \t]+)(.*)/\$1${version}/" \ *.spec diff *.spec.orig *.spec # build package echo "TODO: rpmbuild" # revert spec file changes git reset --hard ''' } pipeline { agent { node 'sys-rhel7-x64' } triggers { pollSCM('H * * * *') } stages { stage ('Prepare') { steps { RPMSource(); } } stage ("RPM Build") { steps { RPMBuild() } } } }