def setup(self): setup_step = Step(type='a', build=self.build, command='setup', start_datetime=datetime.datetime.now()) self.build.start_datetime = datetime.datetime.now() self.update_codebase() self.load_buildsteps() setup_step.log = "\n".join(self.stage_output_buffer['setup']) setup_step.end_datetime = datetime.datetime.now() setup_step.save()
def run_build_steps(self): """ Run each build step in order and propagate the results to the DB """ for sha, step in self.build_steps: current_step = Step(build=self.build, command=step, start_datetime=datetime.datetime.now(), sha=sha) self.push_data({ 'type':'step_start', 'step_hash':sha, 'step':step }) # shell out and run the step command then handle the response and output step_output = list() step_process = self.execute_cmd(step) while step_process.poll() is None: line = step_process.stdout.readline() if line: step_output.append(line) self.console_output(line) time.sleep(0.01) self.build_log += step_output # if the return code shows that the task exited normally then the # step passes if step_process.returncode == 0: current_step.state = 'c' self.build_state.append(True) # Non-zero returncode means that the step is failing. else: current_step.state = 'd' self.build_state.append(False) self.push_data({ 'type':'step_complete', 'step_hash':sha, 'state':current_step.get_state_display() }) # save the step execution out to the DB current_step.end_datetime = datetime.datetime.now() current_step.log = "\n".join(step_output) current_step.save()