Skip to content

Commit

Permalink
fix: handle jobs that are still in the queue
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil Narang <[email protected]>
  • Loading branch information
akhilnarang committed Jan 17, 2024
1 parent 4c2f964 commit dbf4123
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dumpyarabot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,13 @@ async def cancel_jenkins_job(job_id: str) -> str:
)
if response.status_code == 200:
return f"Job with ID {job_id} has been cancelled."
else:
return f"Failed to cancel job with ID {job_id}. Status code: {response.status_code}, Response: {response.text}"
elif response.status_code == 404:
response = await client.post(
f"{settings.JENKINS_URL}/queue/cancelItem",
params=httpx.QueryParams({"id": job_id}),
auth=(settings.JENKINS_USER_NAME, settings.JENKINS_USER_TOKEN),
follow_redirects=True,
)
if response.status_code == 200:
return f"Job with ID {job_id} has been removed from the queue."
return f"Failed to cancel job with ID {job_id}. Status code: {response.status_code}, Response: {response.text[:4000]}"

0 comments on commit dbf4123

Please sign in to comment.