summaryrefslogtreecommitdiffstats
path: root/Jenkinsfile
blob: a4792052c5ec64107a1516675324d0d260a1aca7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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()
	    }
	}

    }
}