Closed davbr closed 3 years ago
Can you please provide a small snippet of code which demonstrates this issue?
sure :)
I have created this https://gitlab.com/davbr1/api_test_report which shows my issue.
just clone the repo, setup python and run the script
Can you try using pipelines = project.pipelines.get()
instead of list
?
I believe in some cases the list
doesn't give all the fields and need to use get
. Not 100% sure on this.
i tied this:
pipeline = project.pipelines.get("339877782")
test_report = pipeline.test_report.get()
but unfortunately it gave the same error as before
Okay. I just tested your code locally.
<class 'gitlab.v4.objects.pipelines.ProjectPipelineTestReport'> => {'total_time': 0.0, 'total_count': 2, 'success_count': 2, 'failed_count': 0, 'skipped_count': 0, 'error_count': 0, 'test_suites': [{'name': 'test', 'total_time': 0.0, 'total_count': 2, 'success_count': 2, 'failed_count': 0, 'skipped_count': 0, 'error_count': 0, 'suite_error': None, 'test_cases': [{'status': 'success', 'name': 'ASuccessfulTest', 'classname': 'foo1', 'file': None, 'execution_time': 0.0, 'system_output': None, 'stack_trace': None, 'recent_failures': None}, {'status': 'success', 'name': 'AnotherSuccessfulTest', 'classname': 'foo2', 'file': None, 'execution_time': 0.0, 'system_output': None, 'stack_trace': None, 'recent_failures': None}]}]}
gl = gitlab.Gitlab("http://gitlab.com")
project = gl.projects.get("28262778")
pipelines = project.pipelines.list()
pipeline = pipelines[0]
# https://python-gitlab.readthedocs.io/en/stable/gl_objects/pipelines_and_jobs.html#id10
test_report = pipeline.test_report.get()
print(test_report)
As a note, strange errors can occur when using 'http' instead of 'https' for specifying the Gitlab server. Shouldn't affect this case, but anything that causes a PUT
or POST
action will have errors.
weird! Are you using 2.9.0 from pypi and which python version. I have tried with 3.8 and 3.9
$ pip freeze | grep python-gitlab
python-gitlab==2.9.0
$ python
Python 3.9.6 (default, Jul 16 2021, 00:00:00)
[GCC 11.1.1 20210531 (Red Hat 11.1.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gitlab
>>> print(gitlab.__version__)
2.9.0
this is a bit embarrassing then...but I found the issue.
Even though I where in my .venv vscode was still using an old version of the python-gitlab package (2.6.0).
Thank you for helping be out @JohnVillalovos and sorry for the noise.
Oh. Glad you figured it out! 😊
Description of the problem, including code/CLI snippet
I'm trying to get a pipline's test report but i get the error seen below under Actual Behaviour.
Expected Behavior
test_report = pipeline.test_report.get()
where pipeline is of type
gitlab.v4.objects.ProjectPipeline
returns test report of pipelineActual Behavior
Specifications