tcunit/TcUnit-Runner

Running TcUnit-Runner on an Azure Virtual Machine through Azure Pipelines

vegarosthus opened this issue · 3 comments

Hi all,

I want to run TcUnit-Runner on a Azure-hosted VM. Following the example under Azure Pipelines on the TcUnit-Runner User Manual I registered the VM as a self-hosted agent and installed all prerequisites on it, including TwinCAT 3, Git and TcUnit/TcUnit-Runner. This is my azure-pipelines.yml file

# Demo CI workflow with TcUnit-Runner
name: TcUnit-Runner  
 
trigger:
- simplified-decoupled-dependency
pr:
- simplified-decoupled-dependency
 
pool: 'AC4Build'    # self-hosted agent  
 
steps: 
 
- checkout: self
  displayName: Checkout repository  
 
- task: CmdLine@2
  displayName: Run PLC unit-tests with TcUnit-Runner 
  condition: succeeded()
  inputs:
    failOnStderr: true
    # Start TcUnit-Runner with a timeout of 5 min
    script: '"C:\Program Files (x86)\TcUnit-Runner\LaunchTcUnit.bat" -U 5'
     
- task: PublishTestResults@2
  displayName: Publish TcUnit results
  condition: or(succeeded(),failed())     
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/TcUnit_xUnit_results.xml'

Now, testing my setup by changing my TC project on my developer machine, and pushing it to the Azure repo, I can see the pipeline job starting in Azure DevOps, but the job fails with the following console output

Starting: Run PLC unit-tests with TcUnit-Runner
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.182.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
"C:\Program Files (x86)\TcUnit-Runner\LaunchTcUnit.bat" -U 5
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\agent\_work\_temp\f6f23cbc-b040-41b0-a738-8f209b523d44.cmd""
##[error]Systemet finner ikke angitt bane.
##[error]Cmd.exe exited with code '1'.
Finishing: Run PLC unit-tests with TcUnit-Runner

Sorry for the Norwegian language, but the first error basically translates to "The system cannot find the given path".

Now I am stuck, partly because I am confused as to what the script is trying to do at this point. What file doesn't it find? Any help would be much appreciated.

Hello,

where is TcUnit-Runner installed on your runner, i.e. C:\Program Files (x86)\TcUnit-Runner?

Hi,
Thanks for the quick reply. I found my error 45 mins after posting my issue. The error was that the .yml-file only referred to the agent pool, and not to the specific agent. Thus, it searched for the LaunchTcUnit.bat-file in the wrong VM. It worked like a charm once I changed the "pool" section in my .yml-file from

pool: 'AC4Build' # self-hosted agent

to

pool: 
    name: AC4Build   
    demands:
    - agent.name -equals TcUnitTests # self-hosted agent 

@vegarosthus good job! I'll close this issue.