在python中使用jenkinsapi触发参数化构建 [英] Triggering parameterized build using jenkinsapi in python

查看:964
本文介绍了在python中使用jenkinsapi触发参数化构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码在 jenkinsapi

I am using the following code to create a job in jenkinsapi

from jenkinsapi.jenkins import *
from jenkinsapi.job import *
import os.path
import urllib2

jenkin = Jenkins('http://hudsonserver','hudson','hudson')

file0=open("data.log")
file1=open("full.log")

myJob = Job("http://hudsonserver/job/LTT_JOB/","LTT_JOB", jenkin)
parameters = {"data.log":file0,"full.log":file1,"REQUESTER_EMAIL_ID":"test@test.com"}
print myJob.get_last_buildnumber()

myJob.invoke('check',False,False,3,15,parameters)

在invoke()调用中,我正在使用令牌'check'.似乎由于表示参数的方式而导致调用失败,有人可以告诉以下参数表示是否正确?

In the invoke() call, I am using the token 'check'. It looks like the call is failing due to way parameters are represented, Can anyone tell if the following representation for parameters is correct?

parameters = {"data.log":file0,"full.log":file1,"REQUESTER_EMAIL_ID":"test@test.com"}

如果任何人都可以指出用jenkinsapi编写的示例,我将非常有帮助

I would be really helpful if anyone can point to examples written with jenkinsapi

推荐答案

否,这绝对是不正确的.参数dict将转换为GET参数.文件对象无法转换为字符串.您可以将文件路径作为参数传递,并在CI作业中写入或读取它们.

No, this is definitly incorrect. Paramters dict would be converted to GET parameters. And file objects couldn't be converted to strings. You can pass path to files as parameters and write or read them inside your CI job.

这篇关于在python中使用jenkinsapi触发参数化构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆