Dinomite-Studios / unity-azure-pipelines-tasks

Azure DevOps extension adding tools to build and deploy Unity 3D projects using Azure Pipelines
https://unitydevops.com/
MIT License
121 stars 49 forks source link

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

Open IanMoroney opened 1 year ago

IanMoroney commented 1 year ago

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 commented 1 year ago

@FejZa , have you seen this issue before?

o-litnon commented 1 year ago

Upvote... same issue

FejZa commented 1 year ago

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

Looks to be the same thing. Looking into it.

Wardy125 commented 1 year ago

Any updates on this?

o-litnon commented 1 year ago

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

FeldmannJR commented 1 year ago

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
IanMoroney commented 1 year ago

@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 commented 1 year ago

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

derekfreed commented 1 year ago

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 😐