Skip to content

Commit d46a23b

Browse files
committed
print build url
1 parent 920539b commit d46a23b

File tree

3 files changed

+17
-41
lines changed

3 files changed

+17
-41
lines changed

scripts/trigger_auto_tests/main.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
is_build_success,
1313
is_last_build_successful,
1414
is_shell_uses_package,
15-
trigger_auto_tests_build2,
15+
trigger_auto_tests_build,
1616
)
1717

1818
TC_URL = "http://tc"
@@ -58,18 +58,21 @@ def _run_tests_for_shell(
5858
build_id = None
5959
if is_shell_uses_package(shell_name, tests_info):
6060
if tests_info.re_run_builds:
61-
if is_last_build_successful(tc, shell_name, tests_info):
61+
success, build_url = is_last_build_successful(tc, shell_name, tests_info)
62+
if success:
6263
tc_msg.testIgnored(
6364
shell_name,
6465
f"{shell_name} last auto tests for this package and commit "
65-
f"id was successful, skip it",
66+
f"id was successful, skip it. {build_url}",
6667
)
6768
else:
68-
click.echo(f"{shell_name} Re run automation tests")
69-
build_id = trigger_auto_tests_build2(tc, shell_name, tests_info)
69+
build_id, build_url = trigger_auto_tests_build(
70+
tc, shell_name, tests_info
71+
)
72+
click.echo(f"{shell_name} Re run automation tests. {build_url}")
7073
else:
71-
click.echo(f"{shell_name} Automation tests build triggering")
72-
build_id = trigger_auto_tests_build2(tc, shell_name, tests_info)
74+
build_id, build_url = trigger_auto_tests_build(tc, shell_name, tests_info)
75+
click.echo(f"{shell_name} Automation tests build triggered. {build_url}")
7376
else:
7477
tc_msg.testIgnored(
7578
shell_name,

scripts/trigger_auto_tests/utils/helpers.py

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from pip_download import PipDownloader
88
from pydantic import BaseModel
99

10-
from scripts.trigger_auto_tests.utils.tc_api import TeamCityAPI
11-
1210
REPOS_OWNER = "QualiSystems"
1311

1412

@@ -47,37 +45,10 @@ def is_shell_uses_package(shell_name: str, tests_info: "AutoTestsInfo") -> bool:
4745

4846

4947
def trigger_auto_tests_build(
50-
tc_api: TeamCityAPI,
51-
shell_name: str,
52-
automation_project_id: str,
53-
package_vcs_url: str,
54-
package_commit_id: str,
55-
) -> int:
56-
locator_data = {
57-
"name": shell_name,
58-
"project": automation_project_id,
59-
}
60-
additional_data = {
61-
"triggeringOptions": {"queueAtTop": True},
62-
"properties": {
63-
"property": [
64-
{"name": "conf.triggered_by_project.url", "value": package_vcs_url},
65-
{
66-
"name": "conf.triggered_by_project.commit_id",
67-
"value": package_commit_id,
68-
},
69-
]
70-
},
71-
}
72-
data = tc_api.trigger_builds(locator_data, additional_data=additional_data)
73-
return data.id
74-
75-
76-
def trigger_auto_tests_build2(
7748
tc: TeamCity,
7849
shell_name: str,
7950
tests_info: "AutoTestsInfo",
80-
) -> int:
51+
) -> tuple[int, str]:
8152
bt = tc.projects.get_build_type(
8253
project_locator=f"id:{tests_info.automation_project_id}",
8354
bt_locator=f"name:{shell_name}",
@@ -91,27 +62,29 @@ def trigger_auto_tests_build2(
9162
new_build = Build(build_type_id=bt.id, properties=properties)
9263
update_tc_csrf(tc)
9364
build = tc.build_queues.queue_new_build(body=new_build, move_to_top=True)
94-
return build.id
65+
return build.id, build.web_url
9566

9667

9768
def is_last_build_successful(
9869
tc: TeamCity, shell_name: str, tests_info: "AutoTestsInfo"
99-
) -> bool:
70+
) -> tuple[bool, str]:
10071
bt: BuildType = tc.projects.get_build_type(
10172
project_locator=f"id:{tests_info.automation_project_id}",
10273
bt_locator=f"name:{shell_name}",
10374
)
75+
build_url = ""
10476
for build in bt.get_builds():
10577
params = get_build_params(build)
10678
if (
10779
params["conf.triggered_by_project.url"] == tests_info.vcs_url
10880
and params["conf.triggered_by_project.commit_id"] == tests_info.commit_id
10981
):
11082
is_success = is_build_success(build)
83+
build_url = build.web_url
11184
break
11285
else:
11386
is_success = False
114-
return is_success
87+
return is_success, build_url
11588

11689

11790
def is_build_finished(build: Build) -> bool:

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2
1+
3.0.3

0 commit comments

Comments
 (0)