gpt4 book ai didi

python - 触发 Jenkins 的命令不起作用

转载 作者:行者123 更新时间:2023-12-01 09:09:00 25 4
gpt4 key购买 nike

我是Python新手,

下面是用于触发 Jenkins 项目的 python 脚本。

 '''subprocess for triggering jenkins'''
print("Update Started 2.........subprocess for triggering jenkins.")
#cmd2 = ['curl', c3]
mycmd = r'start chrome/new-tab {}'.format(c3)

n2=subprocess.Popen(mycmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

#wait for the process to terminate
#out, err = n2.communicate()
#errcode = n2.returncode

'''wait until trigger the jenkins'''
print("Wait until trigger the jenkins..................")

# Deadlock is happening here.
n2.wait()
print("Wait done.......................................")

它没有触发该项目,但是,当我在调试状态下尝试时 - 这个地方发生了死锁 n2.wait()

下面是脚本的日志:

Update Started 2.........subprocess for triggering jenkins.
Wait until trigger jenkins..................

更新 1:当我尝试修改时..

n2.wait(10) 

下面是控制台打印的数据。

Traceback (most recent call last):
File "C:/Users/adevaraj/Desktop/Jenkins_CVS_Testing_Apr/CVS_LOG_Compare.py", line 189, in <module>
n2.wait(10)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 1057, in wait
raise TimeoutExpired(self.args, timeout)
subprocess.TimeoutExpired: Command 'start chrome/new-tab http://localhost:8080/job/P16G0804_GM_A2XX_PSS/build?token=A2XX' timed out after 10 seconds

更新 2:Url 正在从 Excel 工作表中获取(该代码未在此处发布)

更新3:

在此代码中,c3 是后端触发器的 url

谁能帮帮我。

最佳答案

我假设您想触发 Jenkins 构建。简单地使用 Jenkins REST API 怎么样。

import requests 
url = "http://localhost:8080/job/P16G0804_GM_A2XX_PSS/buildWithParameters?
arg1=val1&arg2=val2"
response = requests.get(url)
print(response)

希望对您有帮助!

关于python - 触发 Jenkins 的命令不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51819063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com