Uploading Packages on the Self-Hosted Repo Page
Only repository administrators and developers can upload private packages. You can set repository roles on the User Permissions page.
Procedure
To upload a package, perform the following steps:
- Go to the self-hosted repo page. In the left pane, click the target repository to which the private package is to be uploaded.
- Click Upload on the right of the page.
- Set the package parameters, select the file, and click Upload. You are advised not to upload files containing sensitive information such as plaintext accounts and passwords to self-hosted repos.
Detailed configuration for each package type is described below.
Maven Artifacts
- Project Object Model (POM) is the basic working unit of a Maven project. It is an XML file that contains basic project information to describe how to build a project and declare project dependencies. When a build task is run, Maven searches for the POM in the current directory, reads its content, obtains the required configuration information, and builds the target package.
- Maven coordinates: X, Y, and Z are used to uniquely identify a point in the three-dimensional space. In Maven, GAV is used to identify a unique package. It stands for Group ID, Artifact ID, and Version. Group ID indicates a company or organization. For example, Maven core components are in the org.apache.maven organization. Artifact ID indicates the name of the package. Version indicates the version of the package.
- Maven dependencies are crucial for POM files. The building and running of most projects depend on the dependency on other components. Add the dependency list to your POM file. If the App component depends on the App-Core and App-Data components, the configuration is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.companyname.groupname</groupId> <artifactId>App</artifactId> <version>1.0</version> <packaging>jar</packaging> <dependencies> <dependency> <groupId>com.companyname.groupname</groupId> <artifactId>App-Core</artifactId> <version>1.0</version> </dependency> </dependencies> <dependencies> <dependency> <groupId>com.companyname.groupname</groupId> <artifactId>App-Data</artifactId> <version>1.0</version> </dependency> </dependencies> </project>
Uploading a Maven Artifact
POM and GAV upload modes are supported.
Upload Mode |
Description |
---|---|
POM |
GAV parameters are obtained from the POM file. The system retains transitive dependencies of components. |
GAV |
GAV, short for Group ID, Artifact ID, and Version, is the unique identifier of a JAR package. In this mode, GAV parameters are manually specified. The system automatically generates a POM file without any transitive dependency. |
- POM
In POM mode, you can either upload just the POM file or both the POM file and its related components. The uploaded file must match the artifactId and version values specified in the POM. As shown in the following figure, if the artifactId value is demo and the version value is 1.0 in the POM, then the uploaded file must be named demo-1.0.jar.
The POM file structure is as follows:
<project> <modelVersion>4.0.0</modelVersion> <groupId>demo</groupId> <artifactId>demo</artifactId> <version>1.0</version> </project>
The modelVersion tag must exist and the value must be 4.0.0, indicating that Maven2 is used.
If you upload files in both the POM and File area, the artifactId and version values in POM must match the file name in File. For example, if the artifactId value is demo and the version value is 1.0 in POM, then the uploaded file must be named demo-1.0 in File.
- GAV
In the GAV mode, the Group ID, Artifact ID, and Version parameters must be manually specified and they determine the name of the file to upload. Extension indicates the packaging type and determines the file type to be uploaded.
Classifier is used to differentiate artifacts that are built from the same POM but contain different contents. This field is optional. It can contain letters, digits, underscores (_), hyphens (-), and dots (.). If you specify this field, it will be appended to the file name.
Common usage scenario
- Differentiate versions by name, such as demo-1.0-jdk13.jar and demo-1.0-jdk15.jar.
- Differentiate usage by name, such as demo-1.0-javadoc.jar and demo-1.0-sources.jar.
npm Packages
Node Package Manager (npm) is a JavaScript package management tool. An npm package is the item managed by npm, and the npm registry is used to store and manage these packages.
The npm package consists of a structure and file description.
- Package structure: organizes various files in a package, such as source code files and resource files.
- Description file: describes package information. Example: package.json, bin, and lib files
The package.json file in the package is a description file of a project or module package. It contains information such as the name, description, version, and author. The npm install command downloads all dependent modules based on this file.
An example of the package.json file is as follows:
{ "name": "third_use", //Package name "version": "0.0.1", //Version number "description": "this is a test project", // Description "main": "index.js", //Entry file "scripts": { //Script command "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ //Keyword "show" ], "author": "f", //Developer name "license": "ISC", //License agreement "dependencies": { //Project production dependencies "jquery": "^3.6.0", "mysql": "^2.18.1" }, "devDependencies": { //Project development dependencies "less": "^4.1.2", "sass": "^1.45.0" } }
The name and version are the most important fields and must exist. Otherwise, the current package cannot be installed. The two attributes together form the unique identifier of an npm package.
name indicates the name of the package. The first part of the name value, such as @scope/, is mandatory in the self-hosted repo and is used as the namespace. Generally, you can search for name to install and use the required package.
{ "name": "@scope/name" }
version indicates the version of the package, which is in the x.y.z format.
{ "version": "1.0.0" }
Uploading an npm Package
npm packages in .tgz format can be uploaded to self-hosted repos. When uploading packages, you need to set the following parameters.
Parameter |
Description |
---|---|
PackageName |
The value must be the same as that of name in the package.json file. |
Version |
The value must be the same as that of version in the package.json file. |
When uploading a package, ensure that the PackageName starts with a path in the path list added during repository creation. For details, see Table 2 in the help guide.
Example:
The path @test is added when you create an npm registry.
When uploading the package to the registry, make sure that the PackageName starts with @test. If a path outside the path list is used, for example, @npm, the upload will fail.
After the upload is successful, you can find the package in .tgz format in the repository list and the corresponding metadata is generated in the .npm directory.
Uploading a Go Package
Go, also known as Golang, is a programming language developed by Google. Golang 1.11 and later support modular package management. A module is a unit for source code exchange and versioning in Go. A MOD file identifies and manages a module. A ZIP file is a source code package. There are two types of Go modules: v2.0 and later and v2.0 and earlier. The management of the Go module is different between these two versions.
To upload a Go package, you need to upload both a ZIP file and a MOD file and set the following parameters.
Parameter |
Description |
---|---|
zip path |
Complete path of the ZIP file. Valid path formats are:
|
zip file |
Directory structure of the ZIP file. Valid directory structure formats are:
|
mod path |
Complete path of the MOD file. Valid path formats are:
|
mod file |
MOD file content. Valid content formats are:
|
Uploading a PyPI Package
You are advised to go to the project directory (which must contain the setup.py configuration file) and run the following command to compress the package to be uploaded into a wheel (.whl) installation package. By default, this package is generated in the dist directory of your project directory. Note that the Python package management tool pip supports only wheel installation packages.
python setup.py sdist bdist_wheel
You need to set the following parameters.
Parameter |
Description |
---|---|
PackageName |
The value must be the same as that of name in the setup.py file. |
Version |
The value must be the same as that of version in the setup.py file. |
After the upload is successful, you can find the installation package in .whl format in the repository list. In addition, the corresponding metadata is generated in the .pypi directory, which can be used for pip installation.
Uploading an RPM Package
Red Hat Package Manager (RPM), developed by Red Hat, is used by many Linux distributions. It is a software management system that installs software on Linux in database recording mode.
You are advised to package and name the RPM binary file according to the following rules:
Software name-Main version number of the software.Minor version number of the software.Software revision number-Number of software compilation times.Hardware platform suitable for the software.rpm
For example, hello-0.17.2-54.x86_64.rpm. hello is the software name, 0 is the major version number of the software, 17 is the minor version number, 2 is the revision number, 54 is the number of times that the software is compiled, and x86_64 is the hardware platform suitable for the software.
Software Name |
Major Version |
Minor Version |
Revision No. |
Compilation Times |
Applicable Hardware Platform |
---|---|---|---|---|---|
hello |
0 |
17 |
2 |
54 |
x86_64 |
Note: You need to set the following parameters when uploading packages.
Parameter |
Description |
---|---|
Component |
Component name |
Version |
Version of the RPM binary package |
- Go to the self-hosted repo page. In the left pane, click the target repository to which the private package is to be uploaded.
- Click Upload on the right of the page.
- Set the package parameters, select the file, and click Upload.
After the upload is successful, you can find the RPM binary package in the repository list and the corresponding metadata repodata directory is generated in the package name directory. You can use Yum to install the package.
Uploading a Debian Package
When uploading a Debian package, you need to set the following parameters:
Parameter |
Description |
---|---|
Distribution |
Release version of the package |
Component |
Name of the package |
Architecture |
Package architecture |
Path |
Path for storing the package. By default, the package is uploaded to the root path. |
File |
Local storage path of the package to be uploaded |
After the upload is successful, you can find the installation package in .deb format in the repository list. In addition, the corresponding metadata is generated in the dists directory, which can be used for Debian installation.
Uploading a NuGet Package
A NuGet package is a single ZIP file with a .nupkg extension. You can use the NuGet package to share code specific to an organization or workgroup.
CodeArts Artifact supports uploading local NuGet packages to the self-hosted repo.
You are advised to package and name the NuGet file according to the following rules:
Software name-Major version number of the software.nupkg
Example: automapper.12.0.0.nupkg
- Go to the self-hosted repo page. In the left pane, click the target NuGet repository to which the private package is to be uploaded.
- Click Upload, select the NuGet file to be uploaded from the local PC, and click Upload.
- View the package that is successfully uploaded in the repository list.
metadata stores metadata and is named after the package name. metadata cannot be deleted manually. It will be deleted or added automatically when the corresponding package is deleted or restored.
package stores components.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot