GitHub as Maven Repository | Error creating blob: Not Found (404)

227 Views Asked by At

Following are the steps that I have completed for using GitHub as a Maven Repository

  • Created a new public repository: https://github.com/keshavram-roomie/library
  • Went to https://start.spring.io and generated a maven project as is.
  • Added maven-deploy-plugin
    <plugin>
       <artifactId>maven-deploy-plugin</artifactId>
       <version>2.8.1</version>
       <configuration>
          <altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
       </configuration>
    </plugin>
  • Added site-maven-plugin
    <plugin>
       <groupId>com.github.github</groupId>
       <artifactId>site-maven-plugin</artifactId>
       <version>0.11</version>
       <configuration>
          <message>Maven artifacts for ${project.version}</message>
          <!-- git commit message -->
          <noJekyll>true</noJekyll>
          <!-- disable webpage processing -->
          <outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
          <!-- matches distribution management repository url above -->
          <branch>refs/heads/mvn-repo</branch>
          <!-- remote branch name -->
          <includes>
             <include>**/*</include>
          </includes>
          <repositoryName>library</repositoryName>
          <!-- github repo name -->
          <repositoryOwner>keshavram-roomie</repositoryOwner>
          <!-- github username  -->
       </configuration>
       <executions>
          <!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->
          <execution>
             <goals>
                <goal>site</goal>
             </goals>
             <phase>deploy</phase>
          </execution>
       </executions>
    </plugin>
  • Created ~/.m2/settings.xml
    <settings>
        <servers>
            <server>
                <id>github</id>
                <username>keshavram-roomie</username>
                <password>password</password>
            </server>
        </servers>
    </settings>
  • Executed chmod 700 ~/.m2/settings.xml
  • Hit mvn deploy -e -X

The following are the last lines of errors

[DEBUG] Using 'github' server credentials
[DEBUG] Using basic authentication with username: keshavram-roomie
[DEBUG] Creating blob from /path/to/project/target/mvn-repo/com/roomie/library/0.0.1-SNAPSHOT/library-0.0.1-20230830.110614-2.jar.md5
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.692 s
[INFO] Finished at: 2023-08-30T16:36:24+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project library: Error creating blob: Not Found (404) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project library: Error creating blob: Not Found (404)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating blob: Not Found (404)
Caused by: org.eclipse.egit.github.core.client.RequestException: Not Found (404)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

It seems like it's trying to read a file that was just generated but couldn't find it. Because when I checked, the file was there. Is it possible that the folder is not being refreshed?

1

There are 1 best solutions below

0
VonC On BEST ANSWER

Check first if this is similar to this answer, which stated:

  • When using GitHub's Site Plugin for maven, repositoryName has to be the name of the repository only, in this case library. (you did that)
  • the password needs to be a token

Regarding the second point, "Working with the Apache Maven registry" confirms:

You need an access token to publish, install, and delete private, internal, and public packages.

You can use a personal access token (classic) to authenticate to GitHub Packages or the GitHub API. When you create a personal access token (classic), you can assign the token different scopes depending on your needs. For more information about packages-related scopes for a personal access token (classic), see "About permissions for GitHub Packages".

To authenticate to a GitHub Packages registry within a GitHub Actions workflow, you can use:

  • GITHUB_TOKEN to publish packages associated with the workflow repository.
  • a personal access token (classic) with at least read:packages scope to install packages associated with other private repositories (which GITHUB_TOKEN can't access).

So double-check your password: it must be a token, not your actual GitHub user account password.