1

I'm trying to execute multiple python scripts within Azure DevOps pipeline but the "##[error]Cmd.exe exited with code '5'." is returned with no identification of any testcase apparently.

In the "execute script" step of the pipeline, the following command has been written:

 "C:\Program Files\Python\Python38\python.exe"  -m pytest $(System.DefaultWorkingDirectory)\autotest_main.py -v --junitxml=test-results.xml --html=report.html --self-contained-html

and this works fine untile the script "autotest_main.py" contains just the suite with the test cases. But I need to organize a lot of test cases, so the starting point is the autotest_main.py script that is written as follows:

import os

os.system('test_Preconditions.py')
os.system('test_Suite1.py')
os.system('test_Suite2.py')
os.system('test_Suite3.py')
os.system('test_Suite4.py')

I also used the test_ notation to make the testcases easy to be identified. Each of the test_Suite1.py file contains than the unit tests in conjunction with selenium webdriver to test the frontend of a web application. When I run the script on the local machine everything works fine but when I run it using azure devops the "##[error]Cmd.exe exited with code '5'." is returned. Here the log:

##[section]Starting: execute script
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.176.1
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
"C:\Program Files\Python\Python38\python.exe"  -m pytest C:\agent\_work\12\s\autotest_main.py -v --junitxml=test-results.xml --html=report.html --self-contained-html
========================== Starting Command Output ===========================
##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\agent\_work\_temp\b653526f-53a0-4ac7-8a22-50698ed4ba58.cmd""
============================= test session starts =============================
platform win32 -- Python 3.8.3, pytest-6.1.0, py-1.9.0, pluggy-0.13.1 -- C:\Program Files\Python\Python38\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.8.3', 'Platform': 'Windows-10-10.0.14393-SP0', 'Packages': {'pytest': '6.1.0', 'py': '1.9.0', 'pluggy': '0.13.1'}, 'Plugins': {'html': '2.1.1', 'metadata': '1.10.0', 'nunit': '0.6.0'}}
rootdir: C:\agent\_work\12\s
plugins: html-2.1.1, metadata-1.10.0, nunit-0.6.0
collecting ... collected 0 items
 
---------- generated xml file: C:\agent\_work\12\s\test-results.xml -----------
--------- generated html file: file://C:\agent\_work\12\s\report.html ---------
============================ no tests ran in 0.32s ============================
##[error]Cmd.exe exited with code '5'.
##[section]Finishing: execute script

Any suggestion to fix this problem? I want to possibly prevent to write a lot of execute script steps within the Azure Pipeline if possible.

  • I would suggest you remove `CALL` from your `cmd.exe` `/C` argument. `cmd.exe` shouldn't require the `/S` option either! – Compo Oct 30 '20 at 01:16
  • Share your autotest_main.py script as well. – Harshita Singh Oct 30 '20 at 10:35
  • There was a typo, there is no autotest.py file but only autotest_main.py, so I edited the question again. – Donato Di Pierro Oct 30 '20 at 12:25
  • @DonatoDiPierro, is there a particular reason why you logged in and posted a response to a comment within two hours, but ignored the previous comment made ten hours sooner? You have logged in again three hours later than that too, so I'm unsure why specifically, you've not responded! – Compo Oct 30 '20 at 18:24
  • @Compo I'm so sorry but I am not the DevOps administrator, so I have to ask him to try what you suggested and I will let you know if it will work or not, that's the reason. – Donato Di Pierro Oct 31 '20 at 18:19

0 Answers0