Skip to content

Commit 321a6d4

Browse files
committed
update CSRF before triggering a build
1 parent fb0bdff commit 321a6d4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

scripts/trigger_auto_tests/utils/helpers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path, PosixPath
33

44
from dohq_teamcity import Build, ModelProperty, Properties, TeamCity
5+
from dohq_teamcity.rest import RESTClientObject
56
from github import Github, Repository, UnknownObjectException
67
from pip_download import PipDownloader
78
from pydantic import BaseModel
@@ -88,6 +89,7 @@ def trigger_auto_tests_build2(
8889
]
8990
)
9091
new_build = Build(build_type_id=bt.id, branch_name="master", properties=properties)
92+
update_tc_csrf(tc)
9193
build = tc.build_queues.queue_new_build(body=new_build, move_to_top=True)
9294
return build.id
9395

@@ -100,6 +102,12 @@ def is_build_success(build: Build) -> bool:
100102
return build.status.lower() == "success"
101103

102104

105+
def update_tc_csrf(tc: TeamCity):
106+
# if not do this before triggering build it fails with 403: CSRF =/
107+
# https://github.com/devopshq/teamcity/issues/24
108+
tc.rest_client = RESTClientObject(tc.configuration)
109+
110+
103111
class AutoTestsInfo(BaseModel):
104112
number: int
105113
params: dict

0 commit comments

Comments
 (0)