Distribute Packages Using MATLAB Package Repository Service
R2026bA MATLAB® package repository service acts as an intermediary between the MATLAB Package Manager and your organization's artifact management system. The service indexes packages stored in your organization's artifact management system and makes them discoverable and installable from MATLAB. Unlike a folder-based repository, which requires direct access to a shared file system, a repository service is accessible from any machine that can reach its URL. This accessibility makes a repository service suitable for distributed teams, CI/CD pipelines, and environments where packages are managed centrally.
A repository service supports the same installation workflows as MathWorks File Exchange and folder-based repositories. The service also supports publishing, which allows you to upload new package versions directly from MATLAB without manually managing files.
If you are an administrator who wants to set up a repository service for your organization, see MATLAB Package Repository Service on GitHub.
Add Repository Service
When you add a repository service to your list of known repositories, MATLAB queries it alongside any folder-based repositories during package search and installation operations. MATLAB searches repositories in the order they appear in the list and stops at the first matching package.
Before you add a repository service in MATLAB, request the following information from your repository administrator:
Service URL — The base URL where the repository service is running (for example,
https://packages.example.com). The service must be reachable from your machine.Authentication — Whether the service requires an access token and, if so, how to obtain one from your organization's identity provider.
Configuration — JSON configuration file that contains metadata for the repository service.
Set Access Token
If the repository service requires an access token, you must first set that token. Get
the token from your organization's identity provider, as directed by your repository
administrator. The following commands show how to set your access token depending on your
operating system. You can add the relevant command to a shell profile
(.bashrc, .zshrc, or equivalent) so that the token
persists across MATLAB sessions.
On Windows:
set ARTIFACTORY_TOKEN=<your-read-token>
On Linux/macOS:
export ARTIFACTORY_TOKEN=<your-read-token>
Alternatively, you can use MATLAB secrets to set the access token. For more information, see Keep Sensitive Information Out of Code.
Add Repository Service to Repository List
In MATLAB, register the repository service. For example, given the repository
configuration file from the repository administrator, create a
matlab.mpm.RepositoryConfiguration object and use it to add the
repository service to the list of repositories known to MATLAB.
jsonFile = "/path/to/repo-config.json";
cfg = matlab.mpm.RepositoryConfiguration(jsonFile);
mpmAddRepository(cfg)A repo-config.json file contains metadata for the repository
service. For example, this JSON code shows the metadata for a repository service that
connects to JFrog Artifactory.
{
"schema_version": "1.0.0",
"repository_configuration": [
{
"name": "corp-repo",
"url": "https://mprs.corp.com:8080/",
"type": "artifactory",
"auth": {
"type": "token",
"access_token": "${ARTIFACTORY_TOKEN}"
}
}
]
}MATLAB resolves the ${ARTIFACTORY_TOKEN} placeholder from your
environment variable or MATLAB vault at run time. Do not store tokens directly in the file. You can request
this configuration file from your repository administrator, who might distribute the file
to you through internal documentation, a shared drive, or source control.
Install Packages from Repository Service
After adding the repository service to MATLAB, you can install packages from the service the same way as packages from any other repository, by using the MATLAB Package Manager.
For example, install the MyToolbox package.
mpminstall("MyToolbox")\Publish Packages to Your Repository
You can publish packages to the repository service manually using a command-line HTTP client or from a CI pipeline (GitHub, for example).
This command publishes a package to a repository service connected to JFrog Artifactory:
curl -X POST https://mprs.corp.com:8080/v1/packages \
-H "Authorization: Bearer ${ARTIFACTORY_TOKEN}" \
-F "file=@MyToolbox.mltbx"The service returns 201 Created with the generated manifest JSON
file. If a package with the same UUID and version already exists, then the service returns
409 Conflict.
If an upload fails, the service returns an error. Repository administrators can clean up any files and folders left by an incomplete upload in the artifact management system.
As an alternative to publishing manually, you can automate the publishing process using a CI pipeline. In GitHub this can be set up using:
- name: Publish package
run: |
curl -X POST https://mprs.corp.com:8080/v1/packages \
-H "Authorization: Bearer ${{ secrets.ARTIFACTORY_TOKEN }}" \
-F "file=@build/MyToolbox.mltbx"See Also
Functions
mpminstall|mpmAddRepository|mpmListRepositories|mpmRemoveRepository|matlab.mpm.RepositoryConfiguration