Skip to content

Commit

Permalink
refactor: use a user specific token
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil Narang <[email protected]>
  • Loading branch information
akhilnarang committed Dec 14, 2023
1 parent 45fe035 commit cab34c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dumpyarabot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
class Settings(BaseSettings):
TELEGRAM_BOT_TOKEN: str

JENKINS_TOKEN: str

JENKINS_URL: AnyHttpUrl
JENKINS_USER_NAME: str
JENKINS_USER_TOKEN: str

SUDO_USERS: list[int] = []

Expand Down
4 changes: 2 additions & 2 deletions dumpyarabot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ async def call_jenkins(args: schemas.DumpArguments) -> str:
f"{settings.JENKINS_URL}/job/dumpyara/buildWithParameters",
params=httpx.QueryParams(
{
"token": settings.JENKINS_TOKEN,
"URL": args.url.unicode_string(),
"USE_ALT_DUMPER": args.use_alt_dumper,
}
),
auth=(settings.JENKINS_USER_NAME, settings.JENKINS_USER_TOKEN),
)
if response.status_code in (200, 201):
return "Job started"
Expand All @@ -37,7 +37,7 @@ async def cancel_jenkins_job(job_id: str) -> str:
async with httpx.AsyncClient() as client:
response = await client.post(
f"{settings.JENKINS_URL}/job/dumpyara/{job_id}/stop",
params=httpx.QueryParams({"token": settings.JENKINS_TOKEN}),
auth=(settings.JENKINS_USER_NAME, settings.JENKINS_USER_TOKEN),
)
if response.status_code == 200:
return f"Job with ID {job_id} has been cancelled."
Expand Down

0 comments on commit cab34c6

Please sign in to comment.