Who we are

We are the developers of Plastic SCM, a full version control stack (not a Git variant). We work on the strongest branching and merging you can find, and a core that doesn't cringe with huge binaries and repos. We also develop the GUIs, mergetools and everything needed to give you the full version control stack.

If you want to give it a try, download it from here.

We also code SemanticMerge, and the gmaster Git client.

Plastic SCM integration with Jenkins CI

Tuesday, June 09, 2015 Josué Yeray 0 Comments

UPDATE January 14, 2020: Read more about the Plastic SCM plugin for Jenkins.


Jenkins is an awesome open-source continuous integration (CI) tool built in Java and based on the Hudson project. The best feature of Jenkins is the ability to extend it using plugins that enable you to integrate it with different build systems such as MSBuild or MSTest.

In this article we will show you how to install and configure a Jenkins server with MSBuild and how to integrate it with Plastic SCM so that each of your commits will trigger builds in Jenkins.

Note: you will need to have the Plastic SCM client installed on the Jenkins CI server.

Prerequisites for the CI Server:

  • Windows Server 2012
  • Jenkins 1.610 (the latest stable version at the time this article was written)
  • Visual Studio 2013
  • Plastic SCM 5

Jenkins installation is pretty straightforward, just go to Jenkins and download the latest version for Windows by selecting it from the list on the right. Next, execute the setup.exe and follow the setup wizard to install it.

When the installation is finished the Jenkins default local website will open in http://localhost:8080 and the automatic configuration for the server will start. When it finishes, you will be presented with the main website (dashboard) where you can create new jobs, perform the system configuration or manage users:

Please note that you will also need to install Visual Studio 2013 on the same server so that you can build any projects supported by Visual Studio and run unit tests automatically using Jenkins. If you only want to build your projects you can do that using MSBuild installed with the .NET Framework. But if you want to run unit tests you will need MSTest installed with Visual Studio.

After you have installed all of the required software on your server it is now time to move forward and integrate Jenkins with MSBuild.

Integrating Jenkins with MSBuild

As we stated earlier, Jenkins can be extended using plugins. One of those plugins adds support for MSBuild. To configure it, just go to the Jenkins local administration website (http://localhost:8080) and click on "Manage Jenkins" in the top left options list:

This will open the "Manage Jenkins" page were you will see a list of options to manage your installation. Click on the fourth option "Manage Plugins":

On the Plugin Manager page you will see a tabbed interface with four tabs:

  • Updates: Plugins installed in the system with available updates.
  • Available: List of all available plugins to be installed.
  • Installed: List of plugins currently installed in the system.
  • Advanced: Advanced options to upload your own plugins.

The list of plugins in the "Available" tab is quite large so the best way to find a plugin is to look for it using the Filter text box located above the tabs on the right side of the screen:

Try typing "MSBuild" to filter all available plugins. When you see the MSBuild plugin, click on the checkbox that is on the left side of the title. If you click on any plugin title, the Jenkins website is opened with information regarding the plugin. By clicking on the checkbox next to the MSBuild plugin and then tapping on the "Install without restart" button below the plugins, the installation will start.

On the installation page, after the plugin is successfully installed, click on "Go back to the top page" link and that will return you to the Jenkins main page.

You are now ready to configure the MSBuild plugin. On the Manage Jenkins page, go to the first option "Configure System" and then scroll down until you find the MSBuild section and click on the "Add MSBuild" button:

You will need to specify a name for the MSBuild integration (as you can define multiple implementations), define the path to MSBuild.exe, add any default parameters and then click on the "Install automatically" checkbox. Now press the "Save" button to add this integration to Jenkins:

You are now ready to integrate Plastic SCM with Jenkins.

Integrating Plastic SCM with Jenkins

Return to the Plugin Manager page and search for PlasticSCM using the filter for Available plugins:

Once the Plastic SCM Plugin is found, click on the checkbox next to it and tap on the "Install without restart" button. Now go to Manage Jenkins > Configure System and scroll down until you find the Plastic SCM settings and configure the correct path to the Plastic SCM cm utility. When the path is correctly configured press the "Save" button:

Notice this will be enough if the system user running the Jenkins service (or daemon) is having Plastic SCM well configured. It's always needed to have the Plastic SCM client configured in order to allow Jenkins to use the CLI for running Plastic SCM commands.

Jenkins is usually installed on a server machine where no real development is done so a very easy way to have the Plastic SCM client configured for all the machine users at once is copying a working "client.conf" file inside the Plastic SCM client directory.

The "client.conf" file is located here: "C:\Users\\AppData\Local\plastic4" or here: "/home//.plastic4".

Creating our integration

On the Jenkins local administration website (http://localhost:8080) click on "New Item" in the top left options list. On the new item page, you will need to specify a name for the task and select the type of project. In this case we are going to select "Freestyle project" then press OK to go to the next step:

On the configuration page you can configure more options like discard old builds, execute concurrent builds, etc. There are also options for Source Code Management so for this example we will select Plastic SCM:

When you select the Plastic SCM option, the configuration will ask you for a selector. To identify the selector of the workspace we want to link to, go to the folder using the system command window and execute the command:

cm ss

This would return the selector to use:

Paste this selector in the selector box in Jenkins.

Next you will need to configure the Build triggers. In this example select Poll SCM. This will poll the selected SCM periodically to check for any changes to build. Set up the schedule by entering it into the Schedule text box:

H/30 * * * *

This would poll the SCM every 30 minutes.

Please note that you need to be careful when setting up the polling schedule. If your team's pull cadence is greater than 30 minutes then it is better to set up a schedule to poll the SCM every hour or every two hours.

The final step is to configure MSBuild in the Build section on the configuration page. Start by clicking on the “Add build step” button and from the dropdown select "Build a Visual Studio project or Solution using MSBuild". You will then be asked for the MSBuild version to use so from the dropdown select the MSBuild configuration you saved earlier. You will then need to specify the build file for MSBuild which is the sln file for your project:

When the configuration is complete simply click on the "Save" button at the bottom of the configuration page.

If you return to the Jenkins dashboard, you will see that the new Task was created and it is ready to poll for changes from Plastic SCM according to the schedule you set up:

If you commit changes to the repository before the next scheduled pass then you will see the CI build launch automatically.

Conclussion

As you can see, with these simple steps you have created a powerful continuous integration scenario to build your projects. Plastic SCM is integrated into the process which allows you to manage your source code, build it and run tests from multiple providers.

0 comentarios: