unity-azure-pipelines-tasks icon indicating copy to clipboard operation
unity-azure-pipelines-tasks copied to clipboard

Issue with UnityTestTask@1 - The "path" argument must be of type string. Received type undefined

Open IanMoroney opened this issue 2 years ago • 9 comments

So, trying to use the example in the docs, and I get the error: The "path" argument must be of type string. Received type undefined when trying to run the task.

This is the debug output from the task:

##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]check path : /Users/user/adoagent/1/_work/_tasks/UnityTestTask_85e57e6f-cb59-4d1d-979f-dd830b51f2fa/1.5.0/task.json
##[debug]adding resource file: /Users/user/adoagent/1/_work/_tasks/UnityTestTask_85e57e6f-cb59-4d1d-979f-dd830b51f2fa/1.5.0/task.json
##[debug]system.culture=en-US
##[debug]testMode=editMode
##[debug]unityProjectPath=/Users/user/adoagent/1/_work/5/s
##[debug]testCategory=undefined
##[debug]testFilter=undefined
##[debug]testResultsPath=Test Results
##[debug]unityEditorsPathMode=unityHub
##[debug]customUnityEditorsPath=undefined
##[debug]unityVersion=undefined
The "path" argument must be of type string. Received type undefined
##[debug]task result: Failed
##[error]The "path" argument must be of type string. Received type undefined
##[debug]Processed: ##vso[task.issue type=error;]The "path" argument must be of type string. Received type undefined
##[debug]Processed: ##vso[task.complete result=Failed;]The "path" argument must be of type string. Received type undefined
Finishing: unitytest

According to the docs, there isn't an input called path. According to the code, unity-test.ts does refer to path and it joins it with task.json. However, in the above debug output, you can see the check path running which shows a full path to the task.json, so I don't know exactly what's going wrong here.

I assume i'm not missing any required input parameter, and my build environment is fine. If i'm missing something, can you let me know what it is?

YAML:

steps:
- task: UnityTestTask@1
  name: unitytest
  inputs:
    testMode: editMode
    unityProjectPath: $(System.DefaultWorkingDirectory)

IanMoroney avatar Feb 21 '23 14:02 IanMoroney

@FejZa , have you seen this issue before?

IanMoroney avatar Feb 23 '23 17:02 IanMoroney

Upvote... same issue

o-litnon avatar Feb 23 '23 19:02 o-litnon

https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/issues/223

Looks to be the same thing. Looking into it.

FejZa avatar Mar 24 '23 10:03 FejZa

Any updates on this?

Wardy125 avatar May 02 '23 11:05 Wardy125

unityProjectPath is a relative path from the $(Build.SourcesDirectory) and a compile-time string. You can use a string, or compile time expansion syntax e.g. ${{variables.projectPath}}

NB: you should checkout your unity project in the pipeline... but you perhaps need to preserve the Unity Library files etc https://github.com/o-litnon/AzurePipelineUnityTasks/blob/350f90f974d34eaf8b781921a484f203b87019e6/azure-pipelines.yml#L33

o-litnon avatar May 21 '23 11:05 o-litnon

Found a workaround in the discord by TheRpgEngineer#6915 You have to use the GetProjectVersion task first, and then pass the version as an argument to the tasks. Example:

- task: UnityGetProjectVersionTask@1
  name: projectversion

- task: UnityTestTask@1
  name: unitytest
  inputs:
    unityProjectPath: $(System.DefaultWorkingDirectory)
    testResultsPath: $(System.DefaultWorkingDirectory)/TestResults
    unityVersion: $(projectversion.projectVersion)
    testMode: editMode
    testCategory: '!PlayMode'

- task: UnityCMDTask@1
  name: unitycmd
  inputs:
    unityVersion: $(projectversion.projectVersion)
    unityProjectPath: $(System.DefaultWorkingDirectory)
    cmdArgs: -executeMethod FirstLight.Editor.EditorTools.BackendMenu.MoveBackendDlls

FeldmannJR avatar Jun 09 '23 12:06 FeldmannJR

@FejZa , it doesn't look like unityVersion is a documented input for UnityTestTask, let alone a required field. Should this be added to the docs, and now marked as a required field?

IanMoroney avatar Jun 12 '23 10:06 IanMoroney

I've also updated the docs here: https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks-docs/pull/17

IanMoroney avatar Jun 12 '23 10:06 IanMoroney

I’m seeing this same issue. Interestingly it works just fine on one Azure DevOps org and then fails in another with the exact same code 😐

derekfreed avatar Aug 14 '23 23:08 derekfreed