Private Repositories

JitPack supports building and installing from private Git repositories. Build artifacts are also kept private and you can only download them if you have access to the Git repository itself.

You can also share your build artifacts (jar, aar) publicly while keeping the source code private. For example, you can easily distribute your library to your users without giving them access to code.

A JitPack Subscription is tied to a specific GitHub/Bitbucket account which can be either a user or an organization. All repositories under that account can be built with JitPack and used by members of the organization.

Note that your GitHub organization may need to approve JitPack in order to access private repositories (Documentation).

Set up

To start using private repositories you will first need to grant JitPack access. Open https://jitpack.io/private and follow the steps:

  1. Click Authorize to get your personal authentication token. Each member of your team needs to get their own token.

  2. Add the token to $HOME/.gradle/gradle.properties:

    • authToken=AUTHENTICATION_TOKEN

    • Then use authToken as the username in your build.gradle:

 repositories {
        maven {
            url "https://jitpack.io"
            credentials { username authToken }
        }
 }
 ```

### Maven setup

JitPack provides a private Maven repository that you can access with an authentication token.

Add the token to $HOME/.m2/settings.xml file:

```xml
<settings>
  <servers>
        <server>
          <id>jitpack.io</id>
          <username>AUTHENTICATION_TOKEN</username>
          <password>.</password>
        </server>
  </servers>
</settings>

The id of the server must be the same you use in your pom.xml for JitPack.io.

Sbt setup

Create a new file $HOME/.sbt/.credentials and insert your authentication token:

realm=JitPack
host=jitpack.io
user=AUTHENTICATION_TOKEN
password=.

Then add this line to your build.sbt:

credentials += Credentials(Path.userHome / ".sbt" / ".credentials")

Note that the realm property in the credentials file is case sensitive and needs to be exactly JitPack.

Leiningen

Add the token to project.clj as the username:

  :repositories [["jitpack" {:url"https://jitpack.io" :username "AUTHENTICATION_TOKEN" :password "."  } ]]

Bitbucket

To use JitPack with Bitbucket private repositories you need to create an App Password. The minimum scope that the password requires is Repositories: read. If you’d like to use Artifact Sharing then the required scope is Repositories: write.

In order to Look Up and manage Bitbucket repositories you should add the App Password to your JitPack account:

  1. Sign In on https://jitpack.io
  2. Click on your username (https://jitpack.io/w/user)
  3. Enter your Bibucket user and App Password

Your user page also shows your access token that you should use in your build tool (Gradle/Maven/Sbt).

GitLab

To use JitPack with GitLab private repositories you need to create a Personal Access Token. The only permission that the password requires is api.

In order to Look Up and manage GitLab repositories you should add the Access Token to your JitPack account:

  1. Sign In on https://jitpack.io
  2. Click on your username (https://jitpack.io/w/user)
  3. Enter your GitLab Access Token

Your user page also shows your JitPack access token that you should use in your build tool (Gradle/Maven/Sbt).

Usage

Once you are set up you can try installing one of your private repositories:

  1. Go to https://jitpack.io/private and ‘Look up’ your private repository.

  2. Follow the instructions and add credentials to your build file if using Gradle:

repositories {
    maven {
        url "https://jitpack.io"
        credentials { username authToken }
    }
}

Then add the dependency to your private repository just like you do with a public one:

dependencies {
    compile 'com.github.User:PrivateRepo:Tag'
}

Private and transitive dependencies

Your private GitHub projects can have dependencies on other GitHub projects. JitPack supports resolution of these dependencies seamlessly and there’s no extra configuration required. The token you use to build the first project will also be used to build it’s dependencies.

For transitive dependencies to work in Gradle the authentication token property needs to be called authToken in all projects.

Permissions

Private repository builds are accessible to you and anyone who has Read permissions for the Git repository itself. For example, you may trigger a build of your library and your colleague will be able to install the library straight away.

Your private repository source code remains private.

Artifact sharing

There are two ways to share your build artifacts - public and private.

Artifact sharing publicly

In some cases you want to distribute your project publicly while keeping the source private. In this case:

  1. Sign In on JitPack.io homepage
  2. Look up your private repository
  3. Click on the Settings icon
  4. Click on the Lock icon to make the builds public:

Private

Once the Lock icon turns to unlocked the project’s build artifacts become public. That means your users will be able to install your library without needing an authentication token.

Artifact sharing privately

Anyone with read access to your Git repo can already download the build artifacts. You can also add additional collaborators on JitPack.io that will have read access to the build artifacts. They will not have access to the source code.

To add collaborators:

  1. Sign In on JitPack.io homepage
  2. Look up your private repository
  3. Click on settings
  4. Add the collaborators GitHub username

Collaborators will need to sign in on JitPack.io to get their own authentication token.

Custom domain

If your organisation’s GitHub url is https://github.com/yourcompany then by default the groupId of your artifacts will be ‘com.github.yourcompany’. If you want to use your own domain name as groupId, you can.

JitPack supports mapping your domain name to your GitHub organization. Then instead of ‘com.github.yourcompany’ groupId you can use ‘com.yourcompany’ while the name of the project and version remains the same.

To enable your own domain name:

  1. Add a DNS TXT record that maps git.yourcompany.com to https://github.com/yourcompany

  2. Go to https://jitpack.io/#com.yourcompany/yourrepo and click Look up. If DNS resolution worked then you should see a list of versions.

  3. Select the version you want and click ‘Get it’ to see Maven/Gradle instructions.

Example: https://jitpack.io/#io.jitpack/gradle-simple

To check that the DNS TXT record was added run the command dig txt git.yourcompany.com. For example:

> dig txt git.jitpack.io
...
;; ANSWER SECTION:
git.jitpack.io.     600 IN  TXT "https://github.com/jitpack"