在python中使用jenkinsapi触发参数化构建

时间:2012-05-10 08:55:40

标签: python jenkins

我使用以下代码在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'。由于方式参数被表示,看起来调用失败,任何人都可以判断参数的以下表示是否正确?

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

如果有人能指出用jenkinsapi写的例子

,我会非常乐于助人

1 个答案:

答案 0 :(得分:0)

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

相关问题