Publish Artifacts from a Maven Project
Suppose you have a project that uses Maven as a build tool and want to publish project artifacts to the newly created Maven repository using:
Note that publishing artifacts with the same package version is not allowed. The server will return the 409 HTTP response. The only exception: The artifacts with the SNAPSHOT prefix can be published to a repository with the enabled snaphsots support.
Publish Maven artifacts using Maven command-line tool
Basically, to be able to publish artifacts of a Maven project, you should configure artifact properties, reference a repository, and specify authentication credentials. This configuration is performed in the pom.xml file.
Open the project's
pom.xmlfile.Specify package properties (the generated package name will be
groupId:artifactId):<groupId>org.company</groupId> <artifactId>sample</artifactId> <packaging>pom</packaging> <version>0.9-SNAPSHOT</version>In the
distributionManagementsection, specify repository ID (it must be a unique repository identifier) and URL:<distributionManagement> <repository> <id>my-repo</id> <url>https://maven.pkg.jetbrains.space/mycompany/p/projectkey/my-maven-repo</url> </repository> </distributionManagement>As it's not secure to store credentials in the VCS, we must use the local user-specific Maven settings:
on Windows:
%HOMEPATH%/.m2/settings.xmlon Linux / macOS:
~/.m2/settings.xml
Open
settings.xmland place the server id (the one from Step 1) and the credentials into theserverssection. Here you must use the credentials of either your own Space account (using a permanent token instead of a password is strongly recommended) or a separate service account:<servers> <server> <id>my-repo</id> <username>admin</username> <password>1234</password> </server> </servers>Done! Now, you can publish project artifacts by using, for example, the
mvncommand-line tool:mvn deploy
Publish Maven artifacts from JetBrains TeamCity
Before configuring TeamCity, make sure your project is configured as described in Publish Maven artifacts using Maven command-line tool. If it's done, then all you need is tell TeamCity the repository id and user credentials (the settings you store in your local settings.xml):
Log in to your JetBrains TeamCity instance.
In Administration, open the project settings.
In Maven Settings, upload the settings file. For example, you can use your local
settings.xmlas a basis. Note that, similar to Gradle, we specify variables instead of specifying the username and password explicitly. The content of the file might look like this:<servers> <server> <id>my-repo</id> <username>${usr}</username> <password>${pwd}</password> </server> </servers>
Now, we have to set these values.
In Administration, in the project settings, open the desired build configuration.
In Parameters, add two system properties for the username and the password. For example:
system.usr (if in Step 3, you've specified
{$usr}).
system.pwd (if in Step 3, you've specified
{$pwd}) In Spec, type password. This will hide the password from logs, reports, and so on.
Finally, you should get something like this:

Add a Maven build step that runs
mvn deploy. Here you should:In Goals, specify deploy.
In User Settings | User settings selection, choose the settings you created in Step 3.

Publishing Maven artifacts using Space Automation
For details, refer to the Space Automation examples.