Beispiel #1
0
 def rerunCI(self, ciName, target_url):
     """
     1. get trigger id
     2. rerun
     """
     pipelineBuildid = target_url.split('/')[-3]
     stage_url = localConfig.cf.get('ipipeConf',
                                    'stage_url') + pipelineBuildid
     res = xlyOpenApiRequest().get_method(stage_url).json()
     triggerId = res['triggerId']
     rerun_url = self.__rerunUrl + str(triggerId)
     query_param = 'pipeTriggerId=%s' % triggerId
     headers = {
         "Content-Type": "application/json",
         "IPIPE-UID": "Paddle-bot"
     }
     res_status_code = xlyOpenApiRequest().get_method(
         rerun_url, param=query_param, headers=headers).status_code
     if res_status_code == 200:
         print('%s_%s rerun success!' % (ciName, target_url))
         logger.error('%s_%s rerun success!' % (ciName, target_url))
     else:
         print('%s_%s rerun failed: %s' %
               (ciName, target_url, res_status_code))
         logger.error('%s_%s rerun failed: %s' %
                      (ciName, target_url, res_status_code))
Beispiel #2
0
 def getStageMessge(self, targetId):
     """
     获取任务的stage 信息
     """
     url = localConfig.cf.get('ipipeConf', 'stage_url') + str(targetId)
     headers = {
         "Content-Type": "application/json",
         "IPIPE-UID": "Paddle-bot"
     }
     response = xlyOpenApiRequest().get_method(url, headers=headers).json()
     return response
Beispiel #3
0
 def rerunJob(self, triggerId):
     """重新构建"""
     rerun_url = 'https://xly.bce.baidu.com/open-api/ipipe/agile/pipeline/doRebuild?pipeTriggerId=%s' % triggerId
     headers = {
         "Content-Type": "application/json",
         "IPIPE-UID": "Paddle-bot"
     }
     query_param = 'pipeTriggerId=%s' % triggerId
     res = xlyOpenApiRequest().get_method(rerun_url,
                                          param=query_param,
                                          headers=headers)
     return res
Beispiel #4
0
 def cancelJob(self, jobId):
     """取消任务"""
     cancel_url = 'https://xly.bce.baidu.com/open-api/ipipe/rest/v1/job-builds/%s/operation-requests' % jobId
     DATA = {"type": "CANCEL"}
     json_str = json.dumps(DATA)
     headers = {
         "Content-Type": "application/json",
         "IPIPE-UID": "Paddle-bot"
     }
     res = xlyOpenApiRequest().post_method(cancel_url,
                                           json_str,
                                           headers=headers)
     return res
Beispiel #5
0
 def getJobList(self, jobStatus):
     """
     this function will get all Container job list. eg.V100/P4 type jobs.
     Args:
         jobStatus(str): job status. running/waiting/sarunning/sawaiting.
         cardType_list(str): card type.
     Returns:
         all_task_list(list): all task list
     """
     url = 'https://xly.bce.baidu.com/open-api/ipipe/rest/v1/paddle-api/status?key=%s' % jobStatus
     param = 'key=%s' % jobStatus
     headers = {
         "Content-Type": "application/json",
         "IPIPE-UID": "Paddle-bot"
     }
     start = int(time.time())
     response = xlyOpenApiRequest().get_method(url, param,
                                               headers=headers).json()
     end = int(time.time())
     print('end-start: %s' % (end - start))
     print(response)
     return response