Esempio n. 1
0
 def start_ci_task(request, task_id, parameter_group_id, project_version):
     ci_task = CITask.objects.get(int(task_id))
     queuetask = TaskQueue()
     queuetask.EnqueueTime = DateTimeHelper.get_local_now()
     queuetask.TaskType = ci_task.TaskType
     queuetask.Command = TaskQueueCommandTypeEnum.TaskQueueCommandType_Start
     queuetask.Priority = 2
     queuetask.Status = TaskQueueStatusEnum.QueueTaskStatus_New
     queuetask.TaskID = int(task_id)
     queuetask.TaskUUID = uuid.uuid1()
     if parameter_group_id:
         queuetask.BuildParameterID = parameter_group_id
     else:
         queuetask.BuildParameterID = CITaskParameterService.default_parameter_group(
             int(task_id))
     queuetask.save()
     ci_task.BuildVersion = ci_task.BuildVersion + 1
     if str(project_version) == '0':
         project_version = VersionService.get_latest_version(
             ci_task.Project)
         if project_version:
             project_version = project_version.id
         else:
             project_version = 0
     ci_task.LastHistory = CITaskService.save_ci_taskhistory(
         request, queuetask, ci_task, project_version)
     ci_task.save(update_fields=['BuildVersion', 'LastHistory'])
     message = "任务ID为:" + str(task_id) + "的执行指令已经下发,请耐心等待。"
     user_id = 0
     if request.user.id:
         user_id = request.user.id
     CITaskService.log_build_activity(user_id, ci_task)
     CITaskService.send_task_enqueue_message()
     return [queuetask.id, message, queuetask.TaskUUID]
Esempio n. 2
0
 def start_taskflow(request, flow_id):
     taskflow = CITaskFlow.objects.get(int(flow_id))
     queuetask = TaskQueue()
     queuetask.EnqueueTime = DateTimeHelper.get_local_now()
     queuetask.TaskType = 6
     queuetask.Command = TaskQueueCommandTypeEnum.TaskQueueCommandType_Start
     queuetask.Priority = 2
     queuetask.Status = TaskQueueStatusEnum.QueueTaskStatus_New
     queuetask.TaskID = int(flow_id)
     queuetask.TaskUUID = uuid.uuid1()
     queuetask.FromName = request.user.id
     queuetask.save()
     # taskflow.LastHistory = CITaskFlowService.save_taskflow_history(request,taskflow,queuetask.TaskUUID)
     taskflow.LastRunTime = DateTimeHelper.get_local_now()
     taskflow.save(update_fields=['LastRunTime'])
     message = "任务流 [" + taskflow.FlowName + "] 的执行指令已经下发,请耐心等待。"
     return message
 def start_flowsection(request, section_id):
     flow_section = CITaskFlowSection.objects.get(int(section_id))
     message = "任务阶段 [" + flow_section.SectionName + "] 的执行指令已经下发,请耐心等待。"
     queuetask = TaskQueue()
     queuetask.EnqueueTime = DateTimeHelper.get_local_now()
     queuetask.TaskType = 7
     queuetask.Command = TaskQueueCommandTypeEnum.TaskQueueCommandType_Start
     queuetask.Priority = 2
     queuetask.Status = TaskQueueStatusEnum.QueueTaskStatus_New
     queuetask.TaskID = int(section_id)
     queuetask.TaskUUID = uuid.uuid1()
     queuetask.FromName=request.user.id
     queuetask.save()
     task_flow = CITaskFlow.objects.get(flow_section.TaskFlow)
     # flow_history = CITaskFlowSectionService.save_taskflow_history(request, task_flow,queuetask.TaskUUID)
     # CITaskFlowSectionService.save_section_history(request, flow_section, flow_history)
     # task_flow.LastHistory = flow_history.id
     task_flow.LastRunTime = DateTimeHelper.get_local_now()
     task_flow.save(update_fields=['LastRunTime'])
     return message
Esempio n. 4
0
    def stop_ci_task(request,task_id):
        command_type=TaskQueueCommandTypeEnum.TaskQueueCommandType_Stop
        tq_uuid=request.GET.get("TaskUUID","")
        tq_tasks = TaskQueue.objects.all().filter(TaskUUID=tq_uuid).filter(Command=command_type)
        if not tq_tasks.exists():
            ci_task=CITask.objects.get(int(task_id))
            queuetask=TaskQueue()
            queuetask.EnqueueTime=DateTimeHelper.get_local_now()
            queuetask.TaskType=ci_task.TaskType
            queuetask.Command=command_type
            queuetask.Priority=7
            queuetask.Status =TaskQueueStatusEnum.QueueTaskStatus_New
            queuetask.TaskID=int(task_id)
            queuetask.TaskUUID=tq_uuid
            queuetask.save()
        else:
            queuetask = tq_tasks[0]

        message="任务ID为:"+str(task_id)+"的取消执行指令已经下发,请耐心等待。"
        CITaskService.send_task_enqueue_message()
        return [queuetask.id,message,queuetask.TaskUUID]