summaryrefslogtreecommitdiff
path: root/master.py
blob: 0c43c91deb40a961c719386df5aa73fd70116e2e (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
from buildbot.process.factory import BuildFactory
from buildbot.steps.shell import ShellCommand
from buildbot.plugins import util
from buildbot.plugins import steps
Property = util.Property
Git = steps.Git

class Column:

    def add_get_definitions(self):
        ''' add a step fetch definitions '''

        default_ref = "cu010-trove/br6/firehose-test-1"
        sha = Property("sha",default=default_ref)
        get_defns_cmd = ['sh','get_definitions.sh',sha]
        shell_cmd = ShellCommand(command=get_defns_cmd,
                                 timeout=self.timeout)
        self.factory.addStep(shell_cmd)

    def format_cmd(self):
        ''' a buildbot shell command to pass the properties to trigger '''

        util_properties = []
        for property in self.properties:
            name = property[0]
            default_str = property[1]
            util_property = Property(name,default=default_str)
            util_properties.append(util_property)
        cmd = ['sh',self.trigger]+util_properties
        return ShellCommand(command=cmd,
                            timeout=self.timeout)

    def __init__(self,
                 name,
                 source_repo,
                 category,
                 trigger,
                 slavenames,
                 properties,
                 timeout=1200,
                 get_definitions=False):
        ''' A worker in CIAT Orchestration which appears as a column in the
            buildbot waterfall '''

        self.name = name
        self.source_repo = source_repo
        self.category = category
        self.trigger = 'triggers/%s' % trigger
        self.slavenames = slavenames
        self.properties = properties
        self.timeout = timeout
        self.get_definitions = get_definitions
        self.factory = BuildFactory()
        self.factory.addStep(Git(
                repourl=self.source_repo,
                mode='incremental'))
        if self.get_definitions:
            self.add_get_definitions()
        self.cmd = self.format_cmd()
        self.factory.addStep(self.cmd)