qdyxmas's Room

Done is better than perfect...

python调用 jenkins动态build服务

import jenkins
import time
import sys
class Build_Baseline():
    def __init__(self,branch = "dev"):    
        self.jenkins_server_url="https://xxxx.xxxx.xxxx"
        self.user_id="xxxxxxxxxxxx"
        self.api_token="xxxxxxxxxxxxxxxxx"
        self.branch = branch
        self.server=jenkins.Jenkins(self.jenkins_server_url, username=self.user_id, password=self.api_token)
        self.job_name = "Baseline_Build_Service"
    def build_base_service(self):
        base_dict = {"environment": self.branch,
        "services":"ai_worker,cad_processor,ppt_service,new_task_center,solar_algorithm,data_service,algorithm,backend,websocket,facade_algorithm", 
        "ai_worker_servers": "xkooltest.3322.org", 
        "cad_processor_servers": "xkooltest.3322.org", 
        "ppt_service_servers": "xkooltest.3322.org",
        "new_task_center_servers": "xkooltest.3322.org", 
        "solar_algorithm_servers": "xkooltest.3322.org",
        "data_service_servers": "xkooltest.3322.org", 
        "algorithm_servers": "xkooltest.3322.org",
        "backend_servers": "xkooltest.3322.org",
        "websocket_servers": "xkooltest.3322.org",
        "facade_algorithm_servers": "xkooltest.3322.org", 
        "baseline_servers": ""}
        self.server.build_job(name = self.job_name,parameters=base_dict,token="xkool_baseline")

    def build_baseline(self):
        base_dict = {"services":"baseline", "ai_worker_servers": "", "cad_processor_servers": "", "ppt_service_servers": "", "new_task_center_servers": "", "solar_algorithm_servers": "", "data_service_servers": "", "algorithm_servers": "", "backend_servers": "", "websocket_servers": "", "facade_algorithm_servers": "", "baseline_servers": "xkooltest.3322.org","environment": self.branch}
        self.server.build_job(name = self.job_name,parameters=base_dict,token="xkool_baseline")
if __name__ == "__main__":
    if len(sys.argv) == 2:
        branch = sys.argv[1]
    else:
        branch = "dev"
    bb = Build_Baseline(branch)
    bb.build_base_service()
    bb.build_baseline()

标签 

1 评论

  1. CharlesVex
    /回复

    “I haven’t seen you in these parts,” the barkeep said, sidling settled to where I sat. “Personage’s Bao.” He stated it exuberantly, as if solemn word of honour of his exploits were shared by settlers about multitudinous a firing in Aeternum. He waved to a unanimated hogshead hard by us, and I returned his gesticulate with a nod. He filled a field-glasses and slid it to me across the stained red wood of the court in the vanguard continuing. “As a betting chains, I’d be willing to wager a honourable piece of enrich oneself you’re in Ebonscale Reach in search more than the drink and sights,” he said, eyes glancing from the sword sheathed on my hip to the capitulate slung across my back. http://images.google.com.sg/url?q=https://renewworld.ru/

评论