aboutsummaryrefslogtreecommitdiff
path: root/utils/mangle-jobs/build-timeout-add.mangle
blob: 142f70aae954ef7ecc3c5dc1c0ce6ff390266b62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Add build-timeout plugin setup for build dependencies

#from lxml.etree import Element
from lxml.etree import fromstring

new_node = """\
    <hudson.plugins.build__timeout.BuildTimeoutWrapper>
      <timeoutMinutes>150</timeoutMinutes>
      <failBuild>false</failBuild>
    </hudson.plugins.build__timeout.BuildTimeoutWrapper>
"""

def mangle(tree):
    if tree.xpath("//hudson.plugins.build__timeout.BuildTimeoutWrapper"):
        # Already there
        return
    tag = tree.xpath('/project/buildWrappers')[0]
    node = fromstring(new_node)
    tag.append(node)
    if node.getprevious():
        node.getprevious().tail += "  "
    node.tail = "\n  "