亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

python的Jenkins接口調用方式

瀏覽:98日期:2022-07-25 17:26:58

本來非常喜歡偷懶

最好就是不干活那種

所以最近在研究把Jenkins模塊集成起來

做成傻瓜界面這樣就給他們用

本人Python搓望大神不要噴,多多指導

jenkins的Python模塊模塊安裝

pip:pip install python-jenkins

easy_install:easy_install python-jenkins

使用:

class jenkins_tools(): def __init__(self): cf = get_conf() self.username = cf.get(’jenkins’, ’username’) self.password = cf.get(’jenkins’, ’password’) self.php_jenkins = ’’’#本?拋約旱?enkins的conf文件 <project>#這里可以去抄jenkins的項目文件夾里面的配置文件 <actions/>#記得不要加xml頭,源碼哪里幫我們加了,自己加就是作死 <description></description>#項目需求不一樣,配置文件也不一樣,你們不要抄我的 <keepDependencies>false</keepDependencies> <properties> <hudson.model.ParametersDefinitionProperty> <parameterDefinitions><hudson.model.StringParameterDefinition> <name>Branch</name> <description></description> <defaultValue>%s</defaultValue></hudson.model.StringParameterDefinition> </parameterDefinitions> </hudson.model.ParametersDefinitionProperty> </properties> <scm /> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <builders> <hudson.tasks.Shell> <command>xxxxxxx</command> </hudson.tasks.Shell> </builders> <publishers/> <buildWrappers/> </project> ’’’ self.java_newjenkins = ’’’#本?諾牧磽庖桓?enkins的conf文件 <project> <actions/> <description></description> <keepDependencies>false</keepDependencies> <properties><hudson.model.ParametersDefinitionProperty> <parameterDefinitions> <hudson.model.StringParameterDefinition> <name>Branch</name> <description></description> <defaultValue>%s</defaultValue> </hudson.model.StringParameterDefinition> </parameterDefinitions></hudson.model.ParametersDefinitionProperty> </properties> <scm /> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <builders><hudson.tasks.Shell> <command>xxxx</command></hudson.tasks.Shell> </builders> <publishers/> <buildWrappers/> </project>’’’ def __conn_jenkins_server(self, url): try: #獲得一個jenkins的操作實例 server = jenkins.Jenkins(url, username=self.username, password=self.password) return server except Exception: logging.warning(’login jenkins failed!’) return None def create_project(self, host_ip, project_name, git_path, git_branch, url, environment): server = self.__conn_jenkins_server(url) if server: server.create_job(project_name, self.php_jenkins)#參數1寫的是項目名稱,參數2是xml文檔 return True else: return None def project_built(self, url, project_name, git_branch):#這個函數作用是構建項目 server = self.__conn_jenkins_server(url) server.build_job(project_name, {’Branch’: git_branch}) def check_project_exist(self, project_name, url):#這個函數是檢查項目是否已經存在雖然寫得很挫忘不要見怪 server = self.__conn_jenkins_server(url) name = server.get_job_name(project_name) if name is None: return False return True

詳細可以看官方文檔:http://python-jenkins.readthedocs.io/en/latest/api.html

補充知識:python調用jenkinsapi

在通過python 調用jenkinsapi的時候,需要對一些作業進行定時對構建

python的Jenkins接口調用方式

報錯:

<title>Error 403 No valid crumb was included in the request</title>n</head>n<body><h2>HTTP ERROR 403</h2>

原因是在jenkins的安全配置里勾選里下面這個選項,在預防跨站點請求,將其勾掉即可。

python的Jenkins接口調用方式

以上這篇python的Jenkins接口調用方式就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 免费看片子 | 亚洲精品香蕉一区二区 | 不卡一区二区在线观看 | 久久精品国产一区二区三区日韩 | 日韩www视频 | 亚洲精品第一区二区三区 | 欧美成人午夜视频免看 | 国产亚洲精品日韩香蕉网 | 国产911情侣拍拍在线播放 | 国产主播啪啪 | 黄色一级黄色片 | 国产美女一区精品福利视频 | 一级一级黄色片 | 麻豆国产高清精品国在线 | 亚洲美女亚洲精品久久久久 | 成年性午夜免费视频网站不卡 | 一级特黄a视频 | 久久久久青草大香线综合精品 | 亚洲欧洲精品在线 | 国产亚洲人成网站在线观看不卡 | 国产在线观看一区精品 | 中国猛少妇色xxxxx | 中国帅小伙gaysextubevideo | 182tv成人午夜在线观看 | 香蕉视频色板 | 在线观看永久免费视频网站 | 黄色欧美一级片 | 91久久国产露脸精品免费 | 午夜影院亚洲 | 国产一二三四五路线 | 黑人巨大两根一起挤进来 | 91免费在线视频观看 | 麻豆性视频| 亚洲精品一区久久狠狠欧美 | 国产91高清在线 | 亚洲自偷自偷首页 | 欧美在线成人午夜网站 | 色y视频| 中国特级黄色片 | 色免费视频| 午夜91|