Leiningen Repositories
Leiningen deploys to and resolves from a CloudRepo Maven repository. A CloudRepo Maven repository
is an ordinary one, so Leiningen needs the repository’s URL in project.clj and a credential.
Before you start
Section titled “Before you start”- A Maven repository to deploy to and resolve from. Creating a Repository shows how to make one.
- A repository token with access to the repository, and Download and publish packages access if you will deploy. Repository Tokens: Create One and Authenticate shows how to create one. Leiningen sends the email address of the account that created the token as the username, and the token as the password.
- Leiningen, installed from its own instructions.
Connect Leiningen
Section titled “Connect Leiningen”Add CloudRepo to :repositories in project.clj. One entry handles both reading and deploying. The URL is the repository’s address without a trailing slash, and the credential comes from the environment:
(defproject com.example/my-library "1.0.0" :dependencies [[org.clojure/clojure "1.12.0"] [com.example/internal-lib "1.2.3"]] :repositories [["cloudrepo-maven" {:url "https://your-org.mycloudrepo.io/repositories/your-repo" :username :env/cloudrepo_username :password :env/cloudrepo_token :sign-releases false}]])An :env/name value is read from the environment variable of that name in upper case, so this entry
reads CLOUDREPO_USERNAME and CLOUDREPO_TOKEN. Set both from your secret store, the first to the email
address of the account that minted the token and the second to the token.
Deploy a library
Section titled “Deploy a library”Deploy by the repository’s id from project.clj:
lein deploy cloudrepo-mavenExpected: Leiningen prints Sending and the path of the jar, the pom and the metadata, each followed by
to https://your-org.mycloudrepo.io/repositories/your-repo/, and exits without an error. The deployed files
show in the repository’s file list in the admin portal.
Leiningen signs a release with GPG unless the repository entry says :sign-releases false. Without it,
lein deploy of a release version stops before it sends anything, with Could not sign and the jar’s path
if gpg has no key for you. A -SNAPSHOT version is not signed. CloudRepo does not ask for a signature, so
if you do not sign your releases, keep :sign-releases false in the entry, as above.
If the version already exists in a repository with Overwrite Protection on, which is the default, CloudRepo refuses the deploy. See Maven Overwrite Protection.
Use a private dependency
Section titled “Use a private dependency”Add the library to :dependencies and let Leiningen fetch it using the same :repositories entry:
lein depsExpected: Leiningen prints Retrieving and the path of the library’s pom and jar, from cloudrepo-maven.
Keep the credential out of project.clj and the shell
Section titled “Keep the credential out of project.clj and the shell”An environment variable is the simplest place for the credential. Where one is awkward, Leiningen reads
credentials from a file of your own, ~/.lein/profiles.clj, in an :auth profile whose key is a regular
expression of the repository URL. The file holds the token in plain text, so keep it readable by you alone
(chmod 600 ~/.lein/profiles.clj):
{:auth {:repository-auth {#"https://your-org\.mycloudrepo\.io/.*" {:username "you@example.com" :password "YOUR_REPOSITORY_TOKEN"}}}}Leave :username and :password out of the :repositories entry when you use this file.
When Leiningen answers 401, 403, 404 or 409
Section titled “When Leiningen answers 401, 403, 404 or 409”401 Unauthorized. The credential was refused or never sent. Leiningen must send the email address of the account that minted the token, and the token itself as the password. A token that has expired or been revoked fails the same way, and the Repository Tokens page in the admin portal shows each token’s status. Check that both environment variables are set in the shell that runslein. IfCLOUDREPO_TOKENis unset,lein depssends no credential and prints this same message, andlein deployprintsNo credentials found forand the repository’s id, then asks for a username and a password at the terminal.403 Forbidden. The token does not have access to this repository, or it has Download packages access and you tried to deploy. Each token is limited to the repositories selected when it was created.Could not find artifact .... The repository holds no such coordinate, or the URL names the wrong organization or repository. A proxy repository that the token cannot reach also answers404, never403.409 Conflict, on deploy. The repository has Overwrite Protection on, and the version already exists. Leiningen prints the status and discards the explanation CloudRepo sends with it. Deploy a new version, or use a-SNAPSHOTversion while you iterate. See Maven Overwrite Protection.
See also Repository tokens, which covers the credential each client uses, and Maven Repositories, which covers Maven and the Maven repository settings.