1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

うっかりgradlew publishでReceived status code 422 from server: Unprocessable Entityを喰らう

Last updated at Posted at 2020-12-23

はじめに

人生初のGithub Packagesへのデプロイに挑戦していた。

とかを読みながら

apply plugin: 'maven-publish'

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = 'https://maven.pkg.github.com/yumetodo/LogisticsPipes'
            credentials {
                username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
                password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
            }
        }
    }

    publications {
        gpr(MavenPublication) {
            artifactId = archivesBaseName
            from(components.java)
        }
    }
}

を追記してgradlew publishすると

> Task :publishGprPublicationToGitHubPackagesRepository FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':publishGprPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'gpr' to repository 'GitHubPackages'
   > Could not PUT 'https://maven.pkg.github.com/yumetodo/LogisticsPipes/rs485/logisticspipes/LogisticsPipes/0.9.4.local/LogisticsPipes-0.9.4.local.jar'. Received status code 422 from server: Unprocessable Entity

Received status code 422 from server: Unprocessable Entityを喰らってしまった。どうすればいいのさ?

解決策を探す

Gradle Maven deploy failing with 422 Unprocessable Entity - Code to Cloud / GitHub Packages - GitHub Support Community

artifacId should be lowercase to be able to push to github packages

artifacIdってなんですか・・・?

第53章 Mavenプラグイン#53.6.4. MavenのPOM生成

archiveTask.baseNameをデフォルト以外の値に設定したときは、uploadTask.repositories.mavenDeployer.pom.artifactIdを同じ値に設定することを忘れないでください。 さもないと、近いうちに、同じビルド内の他プロジェクトで生成されたPOMから、プロジェクトが誤ったartifact IDで参照されてしまうかもしれません。

uploadTaskじゃないけど、そういえばarchivesBaseNameは変更している・・・

Maven Publish Plugin#Identity values in the generated POM

publishing {
    publications {
        maven(MavenPublication) {
            groupId = 'org.gradle.sample'
            artifactId = 'library'
            version = '1.1'
            from components.java
        }
    }
}

なるほど、そこにartifactIdできるのか

結論

apply plugin: 'maven-publish'

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = 'https://maven.pkg.github.com/yumetodo/LogisticsPipes'
            credentials {
                username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
                password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
            }
        }
    }

    publications {
        gpr(MavenPublication) {
+           artifactId = archivesBaseName
            from(components.java)
        }
    }
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?