This collection of unity tasks adds CI/CD tooling for use in Azure Pipelines on Azure DevOps when working with Unity projects.
Works for all Azure agents:
- Windows_NT
- Darwin
- Linux
The base commands execute using the UnityHub CLI and UnityEditor CLI. All Unity command variables can be found in the official documentation for your particular install.
If code coverage is installed in your project:
- The EditorTest Task includes arguments for capturing the coverage results.
- After the tests are concluded:
Step 1: Clone this repo into your Azure project so you can reference it easily in your pipeline. You could optionally copy the files directly into your repository and skip Step 4.
Step 2: Install UnityHub on your build agents
Step 3: Install powershell on your build agents
Step 4: Import this repository as a resource
resources:
repositories:
- repository: templates
type: git
name: AzurePipelineUnityTasks
ref: refs/heads/main
Step 5: Reference the templates by using the name of the resource repository
- template: Git/Task_Clean.yaml@templates
(or without the @templates postfix if the files exist locally)
Example pipeline using:
variables:
projectPath: path/to/project
buildName: NameOfMyGame
stages:
- stage: "WindowsOS_Win"
dependsOn: []
pool:
name: Default
demands:
- Agent.OS -equals Windows_NT
jobs:
- job: Job_Unity
displayName: "Test, Build, Deploy"
timeoutInMinutes: 180
steps:
- template: Git/Task_Clean.yaml@templates
- template: Git/Task_Reset.yaml@templates
- checkout: self
clean: false
lfs: true
fetchDepth: 0
persistCredentials: true
- template: Unity/Tasks_SetupTestBuild.yaml@templates
parameters:
os: win
projectPath: ${{variables.projectPath}}
shouldTest: true
shouldBuild: true
buildTarget: Win64
buildOutputPath: $(Build.ArtifactStagingDirectory)
buildName: ${{variables.buildName}}
modules:
- windows-il2cpp