[英]python script to check Jira status
I need a python script that will check Jira status in particular time interval(1 minutes) and once Jira ticket status is approved it will break the loop and proceed with further step(command: terraform apply).我需要一个 python 脚本,它将在特定时间间隔(1 分钟)内检查 Jira 状态,一旦 Jira 票证状态获得批准,它将打破循环并继续执行进一步的步骤(命令:terraform apply)。 Could you please help out with code.
你能帮忙写代码吗?
Using curl to fetch the Jira status:使用 curl 获取 Jira 状态:
curl -u username:password -X GET -H "Content-Type: application/json" https://server-url/rest/api/2/issue/JRA-1?fields=status curl -u 用户名:密码 -X GET -H "Content-Type: application/json" https://server-url/rest/api/2/issue/JRA-1?fields=status
You can refer to the following program this will resolve this issue您可以参考以下程序这将解决此问题
import time
import json, sys, requests, os
def getStatus():
url = "https://server-url/rest/api/2/issue/JRA-1"
headers = {
"Accept": "application/json",
"Authorization": "Basic base64encodethese(username:password)"
}
response = requests.request(
"GET",
url,
headers=headers
)
jsonResponse = json.loads(response.text)
return jsonResponse["status"]
def main():
while(getStatus != "APPROVED"):
time.sleep(50)
os.system("terraform apply")
Checking Jira status every single minute might to demanding for the server -- eg if it happens too long (24/7) and/or if many other similar requests are sent to the server.每分钟检查一次 Jira 状态可能会要求服务器 - 例如,如果它发生的时间太长(24/7)和/或如果许多其他类似的请求被发送到服务器。
Alternatively, you can discuss with Jira administrators to adjust the workflow.或者,您可以与 Jira 管理员讨论以调整工作流程。 Once the issue is transitioned to APPROVED status, they can trigger/call terraform tasks (via webhooks).
一旦问题转变为 APPROVED 状态,他们就可以触发/调用 terraform 任务(通过 webhooks)。 Only one call is sent.
只发送一个呼叫。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.