Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix for apache-airflow-providers-jenkins JenkinsJobTriggerOperator #22802

Merged
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions airflow/providers/jenkins/operators/jenkins_job_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,18 @@ def poll_job_in_queue(self, location: str, jenkins_server: Jenkins) -> int:
# once it will be available in python-jenkins (v > 0.4.15)
self.log.info('Polling jenkins queue at the url %s', location)
while try_count < self.max_try_before_job_appears:
location_answer = jenkins_request_with_headers(
jenkins_server, Request(method='POST', url=location)
)
try:
location_answer = jenkins_request_with_headers(
jenkins_server, Request(method='POST', url=location)
)
# we don't want to fail the operator, this will continue to poll
# until max_try_before_job_appears reached
except (HTTPError, JenkinsException) as ex:
uranusjr marked this conversation as resolved.
Show resolved Hide resolved
self.log.info(f'polling failed, retry polling. Failure reason: {ex}')
SasanAhmadi marked this conversation as resolved.
Show resolved Hide resolved
try_count += 1
time.sleep(self.sleep_time)
continue

if location_answer is not None:
json_response = json.loads(location_answer['body'])
if (
Expand All @@ -168,6 +177,7 @@ def poll_job_in_queue(self, location: str, jenkins_server: Jenkins) -> int:
return build_number
try_count += 1
time.sleep(self.sleep_time)

raise AirflowException(
"The job hasn't been executed after polling " f"the queue {self.max_try_before_job_appears} times"
SasanAhmadi marked this conversation as resolved.
Show resolved Hide resolved
)
Expand Down