Setting Up Continuous Integrations in Dynamics 365 for Operations

by | Updated December 18, 2017 | Dynamics 365 for Finance and Operations

Previously I showed you how to set up version control in Dynamics 365 for Operations. Now we will look at setting up a continuous integration build for our project.

Let’s say we need to write a method that sorts an array of ItemId values. The method should sort the array in place so we can simply pass in our array and it will be sorted afterward. We’ll start by creating new projects and models called ContinuousIntegration and ContinuousIntegration Test. These projects will consist of a single class each. The first contains a simple method that performs a bubble sort on an array of ItemIds. The second contains a unit test class.

The new projects and models created called ContinuousIntegration and ContinuousIntegration Test, and these projects will consist of a single class each.

Once we verify that the code works as expected and our unit tests all pass, we can submit it to our code repository.

Create a Build agent

Now we need to set up a build agent using the SetupBuildAgent.ps1 PowerShell script found in the C:\DynamicsSDK folder. This script requires us to authenticate to VisualStudio.com using something called a Personal access token. This token is a string of characters that replace your username and password when authenticating to the site.

In my testing, I have found that the build agent must use a Personal access token created by the administrative account for your project. If you later add a user to your project, even if that user has admin privileges for that project, you cannot use an access token from that user.

To create your Personal access token, navigate to VisualStudio.com, log in, click your user icon in the top-right corner, and choose Security.

To create your Personal access token, navigate to VisualStudio.com, log in, click your user icon in the top-right corner, and choose Security.

Click the Add button to create a new Personal access token and give it a name.

Click the Add button to create a new Personal access token and give it a name.

Scroll to the bottom of the page and click Create Token. You must now copy your token value and store it in a safe place until you are done setting up your continuous integration server. This token will only be displayed to you once. When you leave this page you will no longer be able to see its value.

(This is not my actual token.)

The token will only be displayed once so it's important to copy it now or you won't be able to see it again.

On your build VM, open an administrative command prompt and change to the C:\DynamicsSDK directory.

Now we need to call the SetupBuildAgent.ps1 script and pass it the values it needs to connect to our project. At a minimum we need to provide the following parameters:

My command line would look something like this:

Command line

When you press enter, the script will download the latest version of the build agent as a Zip file, extract it to a VSOAgent folder, and create a Windows Service instance.

The script downloaded the latest version of the build agent as a Zip file, extract it to a VSOAgent folder, and create a Windows Service instance.

We can see the Build agent online if we navigate to our dashboard, click the settings button, and choose Agent pools.

View the build agent online.

View and download the build agent online.

If we load the services control panel on our build VM we can see the new Windows service tied to this agent.

Load the services control panel on our build VM we can see the new Windows service tied to this agent.

 

Create a Build Definition

The last step is to create a build definition. The build definition defines what steps will be taken when our continuous integration build runs and even defines when our build will run.

To create the build definition, we will use the BuildEnvironmentReadiness.ps1 PowerShell script.

To create the build definition, we will use the BuildEnvironmentReadiness.ps1 PowerShell script.

When you press enter the script will create the build definition.

Create the build definition.

To see the definition, navigate to your project home and click Build and Release > Builds.

To see the definition, navigate to your project home and click Build and Release > Builds.

To see the definition, navigate to your project home and click Build and Release > Builds.

Click the build definition name to see the details.

Click the build definition name to see the details.

Then click the Edit button to see the build steps.

Then click the Edit button to see the build steps.

To enable Continuous integrations, click the Triggers tab, enable the option, and click Save.

To enable Continuous integrations, click the Triggers tab, enable the option, and click Save.

 

Submitting code changes

Now that we have continuous integrations enabled, every time we submit a change our code will be built and tested. To test this, let’s assume that our requirements have changed and we now must use a quick sort to sort our ItemIds.

Let's submit a change to our code so we now must use a quick sort to sort our ItemIds.

If we refresh our build definitions page, we can see that our continuous integration build has been triggered by our change.

You can see that the continuous integration build has been triggered by the change.

If all goes well the build will be successful, tests will pass, and we can be assured that our branch is stable.

If all worked correctly the build will be successful, tests will pass, and we can be assured that our branch is stable.

 

Related Posts

0 Comments

Submit a Comment

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

Upcoming Events

october

07oct12:00 pm1:00 pmThe Three Paths to Business Central from Dynamics GP

08oct11:00 am12:00 pmConfab with Stoneridge - Livestream - The Vision and Strategy of Microsoft Business Systems

14oct10:00 am10:30 amThe Modern Manufacturer - Managing Complex Cost Modeling

14oct12:00 pm12:30 pmGenerating Custom Inspection or Process Forms

19octAll Day22Stoneridge Connect Fall 2020

22oct11:00 am12:00 pmConfab with Stoneridge - Livestream - Stoneridge Connect Recap

28oct10:00 am10:30 amThe Modern Manufacturer - Engineering Change Management: Introduction of NEW Functionality for Manufacturers Using Dynamics 365

november

11nov10:00 am10:30 amThe Modern Manufacturer - Tears and Trauma of MRP

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X