Get in touch with us!

CI Pipeline for Unity3D projects in Azure DevOps

Prerequisite

A quick guide how to set up Azure and Azure DevOps (VSTS) to automate the build process of your game made in Unity3D. this guide assumes that you have the following:

  • Azure Subscription
  • Azure DevOps Organization
  • A Unity3D game project
  • GIT knowledge
  • Basic Azure and Azure DevOps (VSTS) knowledge

Setup build agent in Azure

  1. Login to your subscription in the Azure Portal (https://portal.azure.com).
  2. Deploy a new virtual machine and select a VisualStudio image (I use VS 2017 latest on windows 10 N), but remembert that W10 only is available on MSDN subscriptions.
  3. Configure the VM to be accessible via RDP (but remember to remove this endpoint when you are done.
  4. Wait for the VM to deploy and start.
  5. Connect to the VM using RDP
  6. On the VM install Unity3D, start it and login. This is required at least if you are using the free license.
  7. Login to Azure DevOps (former VSTS) and configure a new build agent. (Self hosted agent)
  8. Configure the agent
  9. Wait for the agent to become active in the Azure DevOps portal

Prepare your Unity project

  1. Open the project
  2. Create a new folder under assets named editor
  3. Create a new script (C#)
    using System.Collections;
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEngine;public class GameBuilder
    {
    static void build()
    {
    // Place all your scenes here
    string[] scenes = {“Assets/scenes/SampleScene.unity”};
    string pathToDeploy = “bin/windwos64/exeName.exe”;
    BuildPipeline.BuildPlayer(scenes, pathToDeploy, BuildTarget.StandaloneWindows64, BuildOptions.None);
    }
    }
  4. Change the scenes to include your scenes and change the pathToDeploy to a suitable name.

Configure Azure DevOps

  1. Create a new project
  2. Use git to push your game code to the newly created project.
  3. Create a new blank build definition.
  4. Add a powershell step and use this inline script
    $project = “\”
    $arguments = @(
    “-quit”,
    “-batchmode”,
    “-logFile stdout.log”,
    “-projectPath $project”,
    “-executeMethod GameBuilder.build”
    “-username $(unityusername)”,
    “-password $(unitypassword)”
    )
    $processinfo = Start-Process -FilePath “C:\Program Files\Unity\Editor\Unity.exe” -ArgumentList $arguments -PassThru
    Wait-Process -Id $processinfo.Id
  5. Add two new pipeline variables
    • unityusername – your username to unity
    • unitypassword – your password to unity (remeber to check the lock icon to make your password variable a secret)
  6. Finnaly add a publish artifact step and change the Path to publish to bin (pathToDeploy in your GameBuilder class)
  7. Save and queue

The artifacts of this build will be the the win64 version of the Unity player. You can browse and download the artifacts from the portal, to verify the build.

The next step is to release the build, but that’s another story 🙂

Submit a Comment

Your email address will not be published. Required fields are marked *

Starkare tillsammans

Bolag inom bÄde publik och offentlig sektor efterfrÄgar en alltmer kostnadseffektiv, platsoberoende och sÀker digital arbetsplats. DÀrför gÄr nu Altitude 365 och Uclarity samman och bildar ett gemensamt specialistbolag.
FortsÀtt pÄ Altitude 365Kolla in Exobe

Altitude 365 + Uclarity – Årets Modern Work Partner!

Vinnaren Ă€r ett bra exempel pĂ„ hur en “Born in the Cloud” stĂ€ndigt förbĂ€ttrar sitt erbjudande, arbetar nĂ€ra och proaktivt med Microsoft för att hjĂ€lpa kunderna pĂ„ deras digitaliseringsresa. Plus att vi pĂ„ Microsoft verkligen ser fram mot den nya bolags-konstellationen (Altitude 365 + Uclarity) för ett “Starkare Tillsammans”.

Uclarity och Altitude 365 - Starkare tillsammans

Uclarity Àr specialister pÄ digitala möten, telefoni, kontaktcenter och digitalt arbetssÀtt. Altitude 365 Àr specialister pÄ sÀkerhet, mobilitet och hur bolag kan optimera resan till Microsoft365. Nu gör vi gemensam sak och bildar bolag tillsammans.

– Pandemin har tydliggjort behoven av en modern digital arbetsplats och vi har diskuterat ett samgĂ„ende med Altitude 365 under en lĂ€ngre tid. VĂ„ra kunder har behov av specialistkompetens och tillsammans blir vi en ledande specialist inom Digital Workplace-omrĂ„det, sĂ€ger Niklas Olsson Hellström, VD Uclarity AB.

Tommy Clark, Partner, Altitude 365, kommenterar:
– Inget bolag köper det andra utan bĂ„da bolagen fĂ„r lika stora delar i det nya bolaget. VĂ„r ledstjĂ€rna Ă€r att vi blir starkare tillsammans och att vi kan hjĂ€lpa vĂ„ra kunder under hela deras resa.
MÄlet med sammanslagningen Àr att kunna hjÀlpa kunder med bÄde teknik och effektiva arbetssÀtt.

– Det Ă€r dĂ„ vĂ„ra kunder fĂ„r önskad effekt av sin investering i den digitala arbetsplatsen, sĂ€ger Niklas Olsson Hellström.

BĂ„da bolagen har svenska och internationella kunder frĂ„n bĂ„de privat och offentlig sektor. Sammanslagningen resulterar i en organisation pĂ„ 50+ anstĂ€llda baserade i Stockholm, Örebro och Göteborg.

För frÄgor, vÀnligen kontakta;
Tommy Clarke, Partner, Altitude 365 AB, 0703-593854, tommy.clarke@altitude365.com
Niklas Olsson Hellström, VD, Uclarity AB, 0734-198016, niklas.olsson@uclarity.com

FortsÀtt pÄ Altitude 365Kolla in Exobe