jutzig / github-release-plugin

uses the github release api to upload files
69 stars 24 forks source link

java.io.FileNotFoundException when trying to upload release on private repo #37

Closed mprins closed 2 years ago

mprins commented 6 years ago

I have the following config

<plugin>
    <groupId>de.jutzig</groupId>
    <artifactId>github-release-plugin</artifactId>
    <version>1.2.0</version>
    <executions>
        <execution>
            <id>github-upload</id>
            <phase>deploy</phase>
            <goals>
                <goal>release</goal>
            </goals>
            <inherited>false</inherited>
            <configuration>
                <description>release v${project.version}</description>
                <releaseName>v${project.version}</releaseName>
                <tag>${project.artifactId}-${project.version}</tag>
                <artifact>${project.build.directory}/${project.build.finalName}-${project.version}-bin.zip</artifact>
                <overwriteArtifact>true</overwriteArtifact>
            </configuration>
        </execution>
    </executions>
</plugin>

When trying to upload the release zip (tag created by maven-release-plugin) to a private repo I get the following error

[DEBUG] Configuring mojo de.jutzig:github-release-plugin:1.2.0:release from plugin realm ClassRealm[plugin>de.jutzig:github-release-plugin:1.2.0, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'de.jutzig:github-release-plugin:1.2.0:release' with basic configurator -->
[DEBUG]   (f) artifact = /mnt/tera1/home/mark/dev/projects/[PRIVATE REPO]/target/checkout/target/[PRIVATE REPO]-1.0.0-rc2-bin.zip
[DEBUG]   (f) description = release v1.0.0-rc2
[DEBUG]   (f) overwriteArtifact = true
[DEBUG]   (f) releaseName = v1.0.0-rc2
[DEBUG]   (f) repositoryId = scm:git:git@github.com:[ORGANISATION]/[PRIVATE REPO].git
[DEBUG]   (f) serverId = github
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@237340dd
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@290b8985
[DEBUG]   (f) tag = [PRIVATE REPO]-1.0.0-rc2
[DEBUG] -- end configuration --
[DEBUG] Using 'github' server credentials
[ERROR] 
java.io.FileNotFoundException: https://api.github.com/repos/[ORGANISATION]/[PRIVATE REPO]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1890)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1492)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream (HttpsURLConnectionImpl.java:263)
    at org.kohsuke.github.Requester.parse (Requester.java:323)
    at org.kohsuke.github.Requester._to (Requester.java:200)
    at org.kohsuke.github.Requester.to (Requester.java:154)
    at org.kohsuke.github.GitHub.getRepository (GitHub.java:289)
    at de.jutzig.github.release.plugin.UploadMojo.execute (UploadMojo.java:171)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:200)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.135 s (Wall Clock)
[INFO] Finished at: 2018-10-02T13:26:02+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal de.jutzig:github-release-plugin:1.2.0:release (github-upload) on project [PRIVATE REPO]: Failed to create release: https://api.github.com/repos/[ORGANISATION]/[PRIVATE REPO] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal de.jutzig:github-release-plugin:1.2.0:release (github-upload) on project [PRIVATE REPO]: Failed to create release
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:200)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to create release
    at de.jutzig.github.release.plugin.UploadMojo.execute (UploadMojo.java:191)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:200)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.io.FileNotFoundException: https://api.github.com/repos/[ORGANISATION]/[PRIVATE REPO]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1890)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1492)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream (HttpsURLConnectionImpl.java:263)
    at org.kohsuke.github.Requester.parse (Requester.java:323)
    at org.kohsuke.github.Requester._to (Requester.java:200)
    at org.kohsuke.github.Requester.to (Requester.java:154)
    at org.kohsuke.github.GitHub.getRepository (GitHub.java:289)
    at de.jutzig.github.release.plugin.UploadMojo.execute (UploadMojo.java:171)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:200)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)
mprins commented 5 years ago

Also affects 1.3.0

atkawa7 commented 5 years ago

@mprins @jutzig Getting a similar issue as well

atkawa7 commented 5 years ago

@mprins @jutzig After adding debug calls and calling mvnw de.jutzig:github-release-plugin:release -X. I realized the issue. The problem is with the regex and the method repositoryId = computeRepositoryId(repositoryId);. I dont know why the repositoryId is in the following format scm:git:git@github.com:<username>/<repository>.git/<module artificactId>. My pom contains the following

 <scm>
        <url>https://github.com/<username>/<repo></url>
        <connection>scm:git:git@github.com:<username>/<repo>.git</connection>
        <developerConnection>scm:git:git@github.com:<username>/<repo>.git</developerConnection>
        <tag>v0.0.1</tag>
    </scm>

It worked after I added <repositoryId>${github.username}/${github.repository}</repositoryId>.

tjuerge commented 5 years ago

I dont know why the repositoryId is in the following format scm:git:git@github.com:<username>/<repository>.git/<module artificactId>.

@atkawa7 You're using the plugin in a child module of a multi-module project. This is not supported yet - the plugin's repository regexp pattern needs to be updated (provided in PR #44).