summaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/autobuilder/buildsteps/PublishArtifacts.py
blob: 90a2a04059593ae08904d6b73b17ee82fe885494 (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
77
78
79
80
'''
Created on Jan 11, 2013

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2012-2013, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "elizabeth.flanagan@intel.com"
'''

from buildbot.steps.shell import ShellCommand
from twisted.python import log
import os, datetime 
from autobuilder.config import *

class PublishArtifacts(ShellCommand):

    haltOnFailure = False 
    flunkOnFailure = True 
    name = "Publishing Artifacts" 
    def __init__(self, factory, argdict=None, **kwargs):
        self.factory = factory
        self.description = "Publishing Artifacts"
        self.slavedir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-slave"))
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        self.timeout=15000
        DEST=self.getProperty("DEST")
        buildername=self.getProperty("buildername")
        self.basedir=os.path.join(os.path.join(
                                    self.slavedir, buildername), 
                                    "build/build/")
        command=""
        DATESTAMP=datetime.datetime.now().strftime("%Y%m%d")
        log.msg("Publishing " + str(self.artifacts))
        if str(os.environ.get('PUBLISH_BUILDS')) == "True":
            for artifact in self.artifacts:
                log.msg("Publishing " + str(artifact))
                if artifact == "adt_installer":
                    command=command+"mkdir -p " + os.path.join(DEST, "adt_installer") + ";"
                    command=command+"cp -R --no-dereference --preserve=links " + \
                                    os.path.join(self.basedir, "tmp/deploy/images/") + \
                                    "*adt* " + os.path.join(DEST, "adt_installer")
                elif artifact == "adt_installer-QA":
                    command=command+"mkdir -p " + os.path.join(DEST, "adt_installer-QA") + ";"
                    command=command+"cp -R --no-dereference --preserve=links " + \
                                    os.path.join(self.basedir, "tmp/deploy/images/") + \
                                    "*adt* " + os.path.join(DEST, "adt_installer-QA")
                elif artifact == "adtrepo-dev":
                    command=command+"SDKVERSION=`cat ./build/meta-yocto/conf/distro/poky.conf |grep 'DISTRO_VERSION ='|sed 's/DISTRO_VERSION = //'|sed 's/-${DATE}//'|sed 's/\"//g'`;"
                    command=command+"mkdir -p " + os.path.join(DEST, "adt_installer-QA") + ";"
                    command=command+"rm -rf " + os.environ.get("ADTREPO_PATH") + "/$SDKVERSION/" + DATESTAMP
                elif "qemu" in artifact:
                    if artifact == "qemux86-tiny":
                        command=command+"mkdir -p " + DEST + "/machines/qemu/" + artifact + ";"
                        command=command+"cp -R --no-dereference --preserve=links " + DEST + "/machines/qemu/qemux86-tiny;"
                    else:
                        command=command+"mkdir -p " + DEST + "/machines/qemu/" + artifact + ";"
                        command=command+"cp -R --no-dereference --preserve=links " + \
                                        os.path.join(self.basedir, "tmp/deploy/images/") + \
                                        "*"+artifact+"* " + DEST + "/machines/qemu/" + artifact + ";"
                else:
                    command=command+"mkdir -p " + DEST + "/machines/qemu/" + artifact + ";"
                    command=command+"cp -R --no-dereference --preserve=links " + \
                                     os.path.join(self.basedir, "tmp/deploy/images/") + \
                                     "*"+artifact+"* " + DEST + "/machines/qemu/" + artifact + ";"
            self.command = command
        else:
            self.command = "echo 'Skipping Step.'"
        ShellCommand.start(self)

    def describe(self, done=False):
        description = ShellCommand.describe(self,done)
        return description