How to Publish a Jitpack Library for a Private Repository

Ibrar KhanIbrar Khan
2 min read

I've noticed a common trend where most tutorials focus on using public repositories for library distribution. This inspired me to craft a guide specifically for those looking to publish a Jitpack library using a private repository. Here's a step-by-step breakdown:

1. Releasing Your Code

  • Navigate to your GitHub repository.

  • On the right sidebar, locate and click on the "Releases" section.

  • Choose to create a new tag, then finalize it by creating a release.

2. Setting Up Jitpack for Private Repositories

  • Access Jitpack's private repository connection page via this link.

  • In the upper-right corner, find and click on "Sign in to GitHub" for authorization, then allow Jitpack access.

3. Generating an Authentication Token

  • Click the gear icon on the Jitpack page under Lookup button

  • Enter your GitHub username in the "Lookup" field to generate a token.

  • Copy this token for later use in your project.

4. Integrating with Your Project

To utilize Jitpack with your private repository, follow these steps:

  • Step 1: Authorize Jitpack by obtaining your personal access token.

  • Step 2: Append your token to your gradle.properties file:

      authToken=jp_45rmcjigd3ldpqt1imk7a5dhnm
    
  • Step 3: Configure your project's dependency resolution:

      dependencyResolutionManagement {
          repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
          repositories {
              ...
              maven {
                  url "https://jitpack.io"
                  credentials { username authToken }
              }
          }
      }
    

5. Locating Your Repository on Jitpack

  • Return to the Jitpack page and enter your repository's URL.

  • Click on "Lookup" to find your repository.

6. Using Your Private Library

After configuration, you can install any of your private libraries by:

repositories {
    maven {
        url "https://jitpack.io"
        credentials { username authToken }  // Use the generated token from Jitpack
    }
}
dependencies {
    compile 'com.github.User:PrivateRepo:Tag'
}

By following these steps, you can securely publish and use your libraries from private repositories with Jitpack.

0
Subscribe to my newsletter

Read articles from Ibrar Khan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ibrar Khan
Ibrar Khan

AWS Certified DevOps Engineer with 4+ years of experience in micro-service deployment, cloud operation CI/CD, and web server configuration like Nginx, and Apache Tomcat. Have extensive experience in the deployment of applications in the cloud.Also experienced in container base orchestration administration tools like Docker-Swarm, and Kubernetes. Have knowledge of Terraform and Ansible. Also, have knowledge of Agile methodology. I have successfully delivered various projects in a timely manner by working with cross-functional teams and collaborating across teams to deliver value....