Setting Up Continuous Integrations in Dynamics 365 for Operations

By Mark Nelson | September 26, 2017

Setting up continuous integrations in dynamics 365 for 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

Recommended Reading:

Manage U.S. Use Tax on Purchase Orders in Dynamics 365 Finance and Operations

  Managing sales tax requirements on your business purchase can be complicated, but Dynamics 365 Finance and Operations can help […]

Read the Article
5.19.22 Dynamics CRM

How to Write a Great Support Ticket in the Stoneridge Support Portal

Submitting a support ticket through the Stoneridge Support Portal is a quick and effective way to get assistance for any […]

Read the Article

Managing Your Business Through Uncertain Times Using Dynamics 365 Finance and Operations

  Dynamics 365 Finance and Operations (F&O) can help you make informed decisions on how to move your business forward. […]

Read the Article
5.13.22 Power Platform

Using Power BI Object Level Security

  The following article will demonstrate how to use Power BI Object Level Security to disable column data based on […]

Read the Article
5.12.22 Dynamics CRM

How to Use the Stoneridge Support Portal

Stoneridge Software’s support portal is an intuitive and useful function that makes it easy for you to access resources to […]

Read the Article
5.6.22 Dynamics GP

Dynamics GP Transaction Removal: Purchase Orders

  Are you having performance issues with Purchase Orders?  Do you find that there are old Purchase Orders on your […]

Read the Article
5.5.22 Dynamics GP

The Real Story about the Long-Term Future of Dynamics GP Support

I’ve seen a number of people put forward comment that Dynamics GP is going away and you have to get […]

Read the Article

New Features in Dynamics 365 Business Central 2022 Wave 1 Release – Financial Enhancements

The Dynamics 365 Businses Central 2022 Wave 1 Release has a lot of new and exciting features to help your […]

Read the Article
4.29.22 Dynamics GP

Dynamics GP Transaction Removals: Bank Reconciliation

  This is part 2 of a 3 part series on Dynamics GP Transaction Removals. These quick tips will hopefully […]

Read the Article

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X