Setup ‘Azure DevOps’ CI Build for Sitecore Habitat! — Part 3

Sivalingaamorthy Subramaniam
6 min readSep 17, 2018

This is 5 part blog series, in this blog you are going see, how to setup Continuous Integration process (CI) for Sitecore Habitat project. This could be a good reference, for the project teams who want to setup Continuous Integration process (CI) . Feel free to add your comments and share your thoughts!

Part 1: Setup Sitecore Habitat with Sitecore 9.0 Update 2 in 30 Minutes!

Part 2: Setup ‘Sitecore Habitat’ to ‘Azure DevOps’ repository!

Part 3: Setup ‘Azure DevOps’ CI build for Sitecore Habitat

Part 4: Setup ‘Sitecore PaaS’ using Azure Marketplace!

Part 5: Setup ‘Azure DevOps’ CD/Release build for Sitecore Habitat

Update Habitat Gulp Script

  1. Update ‘gulp-config.js’
  • Update the buildToolsVersion to ‘auto’, the default value will be 15.0

2. Update ‘gulpfile.js’

  • Include the below contents into ‘gulpfile.js’
  • The ‘CI-Publish’ task will allow you to set the publish ‘output’ folder path. (you can customize the folder name as required). Also set the ‘CI-Clean’ task with the same path. In this example ‘./output’ is the folder name is considered.
  • The Unicorn Serialization items are copied to ‘Output/Data/Unicorn’ folder, based on the ‘CI-Copy-Items’ task.
Unicorn output folder.
  • Run the ‘CI Build’ task from the Visual Studio ‘Task Runner Explorer’
Run the CI-Build Task
  • Check if the all the project build output is published to ‘Output’ folder in local machine.
All Feature, Foundation, Project build output.
  • Check if all the Unicorn contents are published to ‘output\Data\Unicorn’ folder.
Unicorn Output

3. If you see the Changes in Visual Studio team explorer, you will see all the ‘output’ folder contents will be seen.

4. Since the output folder contents are not required to be pushed/committed to repository, it is better to ignore that folder. So, update the ‘.gitignore’ with ‘Output/*’ and Save.

5. After you ignore the ‘Output’ folder, you will see only 3 pending changes.

6. Update the ‘Package.json’ gulp-msbuild with latest version. The default version will be ‘0.4.4’ the lastest version is ‘0.5.5’

7. Update the ‘nuget.config’ with Sitecore Nuget feeds Path and comment the ‘Sitecore v2’ and ‘Sitecore v3', add the below line

<add key=”SitecoreNuGet” value=”https://sitecore.myget.org/F/sc-packages/api/v3/index.json" />

8. Commit these 5 files to the repository.

  • .gitignore
  • gulpfile.js
  • gulp-config.js
  • package.json
  • nuget.config

7. After you commit these changes to repository check if you are able to see the changes on the repository.

Azure DevOps — CI — Pipeline

  1. Create a New Pipeline
  • Go to Pipelines → Builds → New Pipeline
  • Select your Repository and Continue
  • Choose the template as ‘ASP.NET’ and Apply
  • Rename the Build Pipeline name as ‘SitecoreDevOpsHabitat-CI-Build’
  • Update the ‘Nuget Restore’ task to use the ‘nuget.config’
  • In Build Solution Task, remove the argument in MSBuild Arguments “/p:PackageLocation=”$(build.artifactstagingdirectory)\\”. We need to remove this argument because when the projects are getting build we don’t need to package the output to artifact repository.
  • Disable the ‘Test Assemblies’ and ‘Publish Symbols Path’, as we need to add other tasks.
  • Add a new task ‘npm Install’, by clicking ‘+’
  • Select the ‘Build’ as working folder.
  • Add a new task ‘gulp’, by clicking ‘+’
  • Update the Gulp Task Name as ‘CI-Build’, which we added to the gulpfile.js in the previous step.
  • Add a new task ‘Archive Output’, using by which we can add the ‘output’ folder contents to the ‘.zip’ file.
  • Update the ‘Root folder or File to Archive’ with Output folder, and update the Archive file name with prefix ‘BuildOutput-’
  • Save the build definition ‘SitecoreDevOpsHabitat-CI-Build’

Queue the Build

  1. Click the ‘Queue’

2. Select the Agent Pool as ‘Hosted’ or ‘Hosted 2017’ and click ‘Queue’

  • You will a new build is queued.

3. Wait till the agent completes all the tasks execution.

4. On Successful completion of the build, you will see all the task are succeeded. Check the Log summary, where you can download the output.

5. If you want to see the output of the build, you can check the same in the Summary → Build Artifacts published → Drop

6. In case if you face any build error, re-trigger/queue the build again.

Build Errors

  • If you see any error like below, then update the identifier to public in CreateDictionaryEntryService.cs.

src\Foundation\Dictionary\tests\Services\CreateDictionaryEntryServiceTests.cs(29,30): Error CS0122: ‘CreateDictionaryEntryService’ is inaccessible due to its protection level

Process ‘msbuild.exe’ exited with code ‘1’.

--

--

Sivalingaamorthy Subramaniam

Techie by profession, having decade and half, years of experience. Nature lover, interested in travel, hiking!