Working with Git On-Premises Version Control Server
Introduction
When developing Mendix applications, changes to these applications are stored in a version control system. This system is called Team Server and is part of the Mendix Platform. This means that the application’s files are stored in the Mendix online environment. For more information, see the Version Control Reference Guide.
While using Team Server is the recommended for most Mendix developers, you may prefer to store your application’s files in a system controlled by your own organization. For version control, Mendix uses the Subversion system (also known as SVN) and Git. This document describes how to work with Git version control system.
Prerequisites
Make sure you have completed the following prerequisites:
- Make sure you have the right server provider. We currently only support Git Private Server. For more information, see the Preparing Your Repository section.
- You have an unversioned Mendix app. For more information, see the Creating an App section.
Supported Authentication Mechanisms
Currently, we only support HTTP Basic authentication for Git service providers. With most providers, this takes the form of using of personal access tokens (PATs).
To use PAT (or another equivalent), you need to specify it in the Password field when Studio Pro requests credentials for the version control server:
Setting Up the Environment
This section describes how to configure a Git versioned app in Studio Pro. You need a Git server and an initially unversioned Mendix app.
Preparing Your Repository
Mendix supports multiple Git service providers that are listed below. For more information on a specific provider and requirements for it, see System Requirements.
Studio Pro is able to use the following Git server providers:
- Azure DevOps Server
- Azure Repos
- GitHub.com
- GitHub Enterprise Edition
- GitLab.com
- GitLab EE
- GitLab CE
- Bitbucket.org
- Bitbucket Server
- Bitbucket Data Center
You need to create a private repository in the selected provider and create a personal access token (PAT) to provide access to it. The PAT is used as a password.
To interact with this private repository from Studio Pro, you need a link to the repository and a PAT.
Preparing Studio Pro for Git
To use on-premise Git, you need to configure name and email values that will be used to identify your commit in Studio Pro by navigating to Edit > Preferences > Version Control:
Studio Pro now is set up to support Git.
Creating an App
Create an unversioned app in Studio Pro:
Once the app is created, you can upload it to your private Git repository. For more information on how to upload it, see the Uploading to the Private Git Server section below.
Downloading from a Private Repository
Now that you have a Git app on your server, you can download it to another directory or one of your team members can download it on their machine. Follow the steps below:
-
Under Version Control > Download from Version Control Server, select the Private server option and enter the URL of your repository, which contains the app you want to download. If you are not sure what URL to use, you can find this info in your Git server.
-
If you have both Subversion and Git enabled for the private version control in your preferences in Studio Pro, specify which version control system your repository uses. For this case, enable the Git radio button:
-
Enter the link to the repository in the App repository address and click Connect. Now you will have the option to change the directory where the app is downloaded to:
-
Click OK.
-
In the Sign In dialog box, enter your credentials:
-
Enter username (it can be anything except empty) and use the PAT you saved earlier as the password.
The app is downloaded and ready to be used with version control.
Opening the Existing Git App
There are a few ways to open a Git Mendix app, as long as you have Studio Pro Git support activated.
Recent Apps List
In your Recent Apps list, you can click the app name and the app will open.
Recent Apps Menu
Under File > Recent Apps, you can select the app and open it.
Open App Form
The Open App form is accessible from two different places:
- Open App button on the My Apps tab
- Under menu File > Open App
In a form, there are two ways to open a Git app, by opening it from a previous checkout or by opening it locally on disk:
For the previous checkout method do the following:
-
Open from previous checkout.
-
Enable the Private server radio button and enter the link to the repository.
-
Click Connect.
-
If you have checked out the app at least once, you can then pick one of the existing locations on disk and the app will open (shown here with two previous checkouts):
For the previous local disk method do the following:
-
Select the Locally on disk option.
-
In a file browser dialog box, browse to the directory containing your app and double-click the .mpr file (or select it and click Open):
Uploading to the Private Git Server
Once you have an unversioned app, you can upload it to your private team server.
To upload your app, do the following:
-
Open the app in Studio Pro and go to Version Control > Upload to Version Control Server:
-
In the Upload to Version Control Server dialog box, select Private server.
-
Select Git as the private server type (if you have both Subversion and Git enabled in the Preferences Form).
-
Enter the link to the repository you want to upload this app to and click OK:
It might ask you to sign into the server, depending on whether you have previously signed in and choose to stay logged in.
-
You can see the upload process in the Upload Project to Team Server pop-up window.
The app is uploaded successfully. You can check on your private server and see that the app is now on the selected repository:
Moving a Subversion App to Git
If you already have an existing versioned app (with Subversion) that you would like to upload to your Git private server instead, you can export it, then re-import it, and uploading it to your server.
This creates an unversioned app, based on the branch you are working on in Studio Pro. This means that you will not get version history or other branches in the Git repo.
You can move the whole app, including branches and history, to the Mendix Git repository by following the instructions in Migrate to Git
Follow the steps below:
-
Once the app is opened, go to File > Export App Package.
-
In the Export App Package dialog box, browse to the location you would like to save the .mpk (Mendix Package) file, or accept the default location, a new packages folder in the root of the application folder. Take note of this location, as you will need it later. You can also rename the .mpk file (for example,MyGitApp.mpk) and the app will be named that way once you import it and upload it to the Git server:
-
The Progress pop-up window appears, and once it is completed, you can close the app in Studio Pro:
-
Now you can import the package again, and from there you can choose to upload it to your Git private server. Go to File > Import App Package:
-
Once the file browser dialog box is open, navigate to the location you save the .mpk file during the export process.
-
In the Import App Package dialog box, select Private server option in the Where should we store your App? section.
-
In the Private Server Type option, select Git (if you have both Subversion and Git enabled in the Preferences form).
-
Enter the link to the private repository in the address textbox and click OK. Remember, the repository must be completely empty, or Studio Pro will not be able to upload an app to it:
-
Click OK.
After the import process is completed, your previous Subversion app will be now versioned using Git.
Note that your previous app still exists, Studio Pro will simply make an unversioned copy and upload it to your private Git server. So, in your Recent Apps list, you will still see both: