Setting up Maven
-
Create the following environment variables depending on the authentication method:
IAM tokenOAuth tokenAPI key-
Get an IAM token for the Yandex account or service account you are going to use for authentication.
-
Create the
REGISTRY_USERNAMEandREGISTRY_PASSWORDenvironment variables:export REGISTRY_USERNAME="iam" export REGISTRY_PASSWORD="<IAM_token>"Where:
REGISTRY_USERNAME: Authentication method.REGISTRY_PASSWORD: Body of the previously obtained IAM token.
Note
The IAM token's lifetime is limited to 12 hours.
-
Get
an OAuth token for the Yandex account you are going to use for authentication. -
Create the
REGISTRY_USERNAMEandREGISTRY_PASSWORDenvironment variables:export REGISTRY_USERNAME="oauth" export REGISTRY_PASSWORD="<OAuth_token>"Where:
REGISTRY_USERNAME: Authentication method.REGISTRY_PASSWORD: Body of the previously obtained OAuth token.
Note
The OAuth token is valid for one year.
-
Create an API key for the service account you are going to use for authentication.
-
Create the
REGISTRY_USERNAMEandREGISTRY_PASSWORDenvironment variables:export REGISTRY_USERNAME="api_key" export REGISTRY_PASSWORD="<API_key>"Where:
REGISTRY_USERNAME: Authentication method.REGISTRY_PASSWORD: Body of the previously created API key.
Note
The API key maximum lifetime is set manually when you create the key.
-
-
Open the file with the global Maven settings.
By default, the configuration file is located in the current user's
.m2directory (~/.m2/settings.xmlfor Unix-like OSes and%USERPROFILE%\.m2\settings.xmlfor Windows). You can learn more about the configuration file structure in the Maven documentation . -
Add a new repository to the
repositoriessection of the Maven settings file:<repository> <id>local</id> <url>registry.yandexcloud.net/maven/<registry_ID></url> </repository> -
Add a new server to the
serverssection of the Maven settings file:<server> <id>local</id> <username>${env.REGISTRY_USERNAME}</username> <password>${env.REGISTRY_PASSWORD}</password> </server>