I have a problem with a simple python script which triggers a jenkins job and returns intermediate results while the jenkins job is running. The script sleeps, checks jenkins again and prints some info to a web browser output. This generally works fine, but on Firefox 90.0.2, I do not get anything but a blank page until the job is done (the job gets triggered though). On edge browser (vers 91.0.864.70) everything works as expected.
Here are relevant parts of my python script:
#!path/python.exe
import requests
import time
import functools
print = functools.partial(print, flush=True)
jenkins_url = "https://xxxx"
auth = ("user", "password")
job_name = "job"
request_url = "{0:s}/job/{1:s}/build?token=tokenName".format(
jenkins_url,
job_name,
)
print("Content-Type: text/html\n")
print("Determining next build number<br>")
job = requests.get(
"{0:s}/job/{1:s}/api/json".format(
jenkins_url,
job_name,
),
auth=auth,
).json()
next_build_number = job['nextBuildNumber']
next_build_url = "{0:s}/job/{1:s}/{2:d}/api/json".format(
jenkins_url,
job_name,
next_build_number,
)
print("Triggering build: {0:s} #{1:d}<br>".format(job_name, next_build_number))
response = requests.post(request_url, auth=auth)
print("Job triggered successfully<br>")
while True:
print("Querying Job current status...<br>")
try:
build_data = requests.get(next_build_url, auth=auth).json()
except ValueError:
print("No data, build still in queue<br>")
print("Sleep for 20 sec<br>")
time.sleep(20)
continue
print("Building: {0}<br>".format(build_data['building']))
building = build_data['building']
if building is False:
break
else:
print("Sleep for 60 sec<br>")
time.sleep(60)
print("Job finished with status: {0:s}<br>".format(build_data['result']))
Any suggestions or hints are greatly appreciated!
Thanks