示例#1
0
    def begin(self):
        # Write the build script, the chdir into the build root.
        self.script_file_name = self._get_script_file_name()
        self.json_file_name = self._get_json_file_name()

        fh = open(self.script_file_name, "w")
        fh.write(self.build.script)
        fh.close()

        fh = open(self.json_file_name, "w")
        fh.write(self.build.variables)
        fh.close()

        self.prev_dir = os.getcwd()
        os.chdir(self.build.working_dir)

        base = self._get_container_base_image()

        self.build.append_message("using container base image: %s" % base)

        context = dict(timeout=(60 * self.build.project.timeout),
                       container_base_image=base,
                       buildroot=self.build.working_dir)
        contents = template(CONTAINER_TEMPLATE, context)

        fh = open("Dockerfile", "w")
        fh.write(contents)
        fh.close()
示例#2
0
文件: command.py 项目: xinity/vespene
    def execute_hook(self, build, context):

        command = self.args
        command = template(command, context)
        commands.execute_command(build,
                                 command,
                                 log_command=True,
                                 output_log=False,
                                 message_log=True)
示例#3
0
文件: shell.py 项目: ynop/vespene
    def scale_worker_pool(self, worker_pool, parameters):
        """
        This plugin just templates out a shell string using Jinja2 and runs it.
        See web docs at docs.vespene.io for an example.
        """

        cmd = worker_pool.executor_command
        cmd = template(cmd, parameters, strict_undefined=True)
        result = self.invoke(worker_pool, cmd)
        LOG.debug(result)
示例#4
0
    def compute(self, project, existing_variables):
        """
        We have to Jinja2-evaluate all the snippets before injecting them into
        the dictionary for the build script evaluation.
        """

        results = dict()
        for x in Snippet.objects.order_by('name').all():
            # FIXME: on error, load something into the template an empty string and log it
            name = x.name.replace("-","_").replace(" ","_")
            results[name] = template(x.text, existing_variables, strict_undefined=False)
        return results
示例#5
0
    def execute_hook(self, build, context):

        LOG.debug("executing slack hook")

        if context['hook'] == 'pre':
            slack_template = PRE_TEMPLATE
        elif build.status == SUCCESS:
            slack_template = SUCCESS_TEMPLATE
        else:
            slack_template = FAILURE_TEMPLATE

        msg = template(slack_template, context, strict_undefined=True)

        self.client.api_call("chat.postMessage", channel=self.channel, text=msg)
示例#6
0
文件: jobkick.py 项目: zypox/vespene
def compute_script(project, build, variable_chain):
    return template(project.script, variable_chain, strict_undefined=True)