Setup Sitecore project’s source code to Azure DevOps repository

  1. Create Project (New) ‘DemoProject’
Azure_Cloud

  • The default repository name will have project name ‘DemoProject’. Select Repository ‘DemoProject’, you will see the message that it is empty.
  • Click on Clone button and get credentials for clone ‘DemoProject’ on your local machine.
Azure_Cloud
Azure_Cloud
  • Using Git credentials clone ‘DemoProject’ on your local machine and also you can push file on Azure Git.

Setup Azure DevOps CI Build for Sitecore Source Code

In this blog part we will see, how to setup Continuous Integration process (CI) for Sitecore Source Code. This will help for the project teams who want to setup Continuous Integration process (CI)

Update Project with below Gulp Script

  1. Update ‘gulp-config.js’

Update the buildToolIsVersion to ‘auto’, the default value will be 15.0

  • Update ‘gulpfile.js’

Include the below content into ‘gulpfile.js’

/*****************************

  CI Publish

  Credits to James – Inspired from : https://www.jameshirka.com/2016/10/sitecore-habitat-deployment/

*****************************/

gulp.task(“CI-Build”, function (callback) {

    runSequence(

        “CI-Clean”,

        “CI-Publish”,

        “CI-Prepare-Package-Files”,

        “CI-Copy-Items”,

        callback);

});

gulp.task(“CI-Publish”, function (callback) {

    config.websiteRoot = path.resolve(“./Output”);

    config.buildConfiguration = “Release”;

    fs.mkdirSync(config.websiteRoot);

    runSequence(

        “Build-Solution”,

        “Publish-Foundation-Projects”,

        “Publish-Feature-Projects”,

        “Publish-Project-Projects”, callback);

});

gulp.task(“CI-Clean”, function (callback) {

    rimrafDir.sync(path.resolve(“./Output”));

    callback();

});

gulp.task(“CI-Copy-Items”, function () {

    return gulp.src(“./src/**/serialization/**/*.yml”)

        .pipe(gulp.dest(‘./Output/Data/unicorn/’));

});

gulp.task(“CI-Prepare-Package-Files”, function (callback) {

    var excludeList = [

        config.websiteRoot + “\\bin\\{Sitecore,Lucene,Newtonsoft,System,Microsoft.Web.Infrastructure}*dll”,

        config.websiteRoot + “\\compilerconfig.json.defaults”,

        config.websiteRoot + “\\packages.config”,

        config.websiteRoot + “\\App_Config\\Include\\{Feature,Foundation,Project}\\z.*DevSettings.config”,

        “!” + config.websiteRoot + “\\bin\\Sitecore.Support*dll”,

        “!” + config.websiteRoot + “\\bin\\Sitecore.{Feature,Foundation,Habitat,Demo,Common}*dll”

    ];

    console.log(excludeList);

    return gulp.src(excludeList, { read: false }).pipe(rimraf({ force: true }));

});

  • 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.
Azure_Cloud
  • Run the ‘CI Build’ task from the Visual Studio ‘Task Runner Explorer
Azure_Cloud
  • Check if the all the project build output is published to ‘Output’ folder in local machine.
Azure_Cloud
  • 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.
Azure_Cloud
  • Update the ‘Package.json’ gulp-msbuild with latest version. The default version will be ‘0.4.4’ the lastest version is ‘0.5.5’
Azure_Cloud
  • 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” />

Azure_Cloud
  • Commit these 5 files to the repository.
  • .gitignore
  • gulpfile.js
  • gulp-config.js
  • package.json
  • nuget.config
  • After you commit these changes to repository check if you are able to see the changes on the repository.
Azure_Cloud

I hope this article will help you to configure the DevOps!

Please let me know if you have any specific issue.

Connect me on Twitter – https://twitter.com/sitecore_ashish or Linkedin – https://www.linkedin.com/in/ashishbansal9/

Happy Sitecoring and Cloud

Leave a Reply

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