@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Git: HTTPS プロトコルで git clone/pull/push する際の HTTP デバッグログを見る

GIT_TRACE=1 以外にも色々な環境変数が指定できる。

HTTP 通信のログを見るには GIT_CURL_VERBOSE=1 を指定する。

debugging - How can I debug git/git-shell related problems? - Stack Overflow

GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone https://github.com/kyanny/hello

macOS 11.5.2 上の git 2.32.0 では以下のような出力になる。

$ GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone https://github.com/kyanny/hello
20:37:11.800261 git.c:455               trace: built-in: git clone https://github.com/kyanny/hello
Cloning into 'hello'...
20:37:11.811327 run-command.c:667       trace: run_command: git remote-https origin https://github.com/kyanny/hello
20:37:11.816890 git.c:743               trace: exec: git-remote-https origin https://github.com/kyanny/hello
20:37:11.817559 run-command.c:667       trace: run_command: git-remote-https origin https://github.com/kyanny/hello
20:37:11.827675 http.c:756              == Info: Couldn't find host github.com in the .netrc file; using defaults
20:37:11.883106 http.c:756              == Info:   Trying 13.114.40.48...
20:37:11.883150 http.c:756              == Info: TCP_NODELAY set
20:37:11.892599 http.c:756              == Info: Connected to github.com (13.114.40.48) port 443 (#0)
20:37:11.892742 http.c:756              == Info: ALPN, offering h2
20:37:11.892768 http.c:756              == Info: ALPN, offering http/1.1
20:37:11.898710 http.c:756              == Info: successfully set certificate verify locations:
20:37:11.898733 http.c:756              == Info:   CAfile: /etc/ssl/cert.pem
  CApath: none
20:37:11.898843 http.c:756              == Info: TLSv1.2 (OUT), TLS handshake, Client hello (1):
20:37:11.907147 http.c:756              == Info: TLSv1.2 (IN), TLS handshake, Server hello (2):
20:37:11.907232 http.c:756              == Info: TLSv1.2 (IN), TLS handshake, Certificate (11):
20:37:11.908281 http.c:756              == Info: TLSv1.2 (IN), TLS handshake, Server key exchange (12):
20:37:11.908673 http.c:756              == Info: TLSv1.2 (IN), TLS handshake, Server finished (14):
20:37:11.908912 http.c:756              == Info: TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
20:37:11.908923 http.c:756              == Info: TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
20:37:11.908955 http.c:756              == Info: TLSv1.2 (OUT), TLS handshake, Finished (20):
20:37:11.918571 http.c:756              == Info: TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
20:37:11.918751 http.c:756              == Info: TLSv1.2 (IN), TLS handshake, Finished (20):
20:37:11.918832 http.c:756              == Info: SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
20:37:11.918850 http.c:756              == Info: ALPN, server accepted to use h2
20:37:11.918860 http.c:756              == Info: Server certificate:
20:37:11.918882 http.c:756              == Info:  subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=github.com
20:37:11.918892 http.c:756              == Info:  start date: Mar 25 00:00:00 2021 GMT
20:37:11.918899 http.c:756              == Info:  expire date: Mar 30 23:59:59 2022 GMT
20:37:11.918918 http.c:756              == Info:  subjectAltName: host "github.com" matched cert's "github.com"
20:37:11.918932 http.c:756              == Info:  issuer: C=US; O=DigiCert, Inc.; CN=DigiCert High Assurance TLS Hybrid ECC SHA256 2020 CA1
20:37:11.918940 http.c:756              == Info:  SSL certificate verify ok.
20:37:11.918966 http.c:756              == Info: Using HTTP2, server supports multi-use
20:37:11.918999 http.c:756              == Info: Connection state changed (HTTP/2 confirmed)
20:37:11.919007 http.c:756              == Info: Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
20:37:11.919098 http.c:756              == Info: Using Stream ID: 1 (easy handle 0x7fa6b002c400)
20:37:11.919131 http.c:703              => Send header, 0000000225 bytes (0x000000e1)
20:37:11.919142 http.c:715              => Send header: GET /kyanny/hello/info/refs?service=git-upload-pack HTTP/2
20:37:11.919148 http.c:715              => Send header: Host: github.com
20:37:11.919154 http.c:715              => Send header: User-Agent: git/2.32.0
20:37:11.919160 http.c:715              => Send header: Accept: */*
20:37:11.919166 http.c:715              => Send header: Accept-Encoding: deflate, gzip
20:37:11.919172 http.c:715              => Send header: Accept-Language: ja-JP, *;q=0.9
20:37:11.919191 http.c:715              => Send header: Pragma: no-cache
20:37:11.924139 http.c:715              => Send header: Git-Protocol: version=2
20:37:11.924203 http.c:715              => Send header:
20:37:11.927870 http.c:756              == Info: Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
20:37:12.120119 http.c:703              <= Recv header, 0000000013 bytes (0x0000000d)
20:37:12.120162 http.c:715              <= Recv header: HTTP/2 200
20:37:12.120171 http.c:703              <= Recv header, 0000000026 bytes (0x0000001a)
20:37:12.120207 http.c:715              <= Recv header: server: GitHub Babel 2.0
20:37:12.120215 http.c:703              <= Recv header, 0000000059 bytes (0x0000003b)
20:37:12.120221 http.c:715              <= Recv header: content-type: application/x-git-upload-pack-advertisement
20:37:12.120257 http.c:703              <= Recv header, 0000000054 bytes (0x00000036)
20:37:12.120263 http.c:715              <= Recv header: content-security-policy: default-src 'none'; sandbox
20:37:12.120270 http.c:703              <= Recv header, 0000000040 bytes (0x00000028)
20:37:12.120278 http.c:715              <= Recv header: expires: Fri, 01 Jan 1980 00:00:00 GMT
20:37:12.120310 http.c:703              <= Recv header, 0000000018 bytes (0x00000012)
20:37:12.120347 http.c:715              <= Recv header: pragma: no-cache
20:37:12.120388 http.c:703              <= Recv header, 0000000053 bytes (0x00000035)
20:37:12.120434 http.c:715              <= Recv header: cache-control: no-cache, max-age=0, must-revalidate
20:37:12.120450 http.c:703              <= Recv header, 0000000023 bytes (0x00000017)
20:37:12.120462 http.c:715              <= Recv header: vary: Accept-Encoding
20:37:12.120473 http.c:703              <= Recv header, 0000000023 bytes (0x00000017)
20:37:12.120483 http.c:715              <= Recv header: x-frame-options: DENY
20:37:12.120496 http.c:703              <= Recv header, 0000000057 bytes (0x00000039)
20:37:12.120503 http.c:715              <= Recv header: x-github-request-id: E57F:0758:10C121B:13B9030:6130B767
20:37:12.120511 http.c:703              <= Recv header, 0000000002 bytes (0x00000002)
20:37:12.120517 http.c:715              <= Recv header:
20:37:12.123002 http.c:756              == Info: Connection #0 to host github.com left intact
20:37:12.123311 http.c:756              == Info: Couldn't find host github.com in the .netrc file; using defaults
20:37:12.123334 http.c:756              == Info: Found bundle for host github.com: 0x7fa69fd046b0 [can multiplex]
20:37:12.123350 http.c:756              == Info: Re-using existing connection! (#0) with host github.com
20:37:12.123359 http.c:756              == Info: Connected to github.com (13.114.40.48) port 443 (#0)
20:37:12.123378 http.c:756              == Info: Using Stream ID: 3 (easy handle 0x7fa6b002c400)
20:37:12.123410 http.c:703              => Send header, 0000000264 bytes (0x00000108)
20:37:12.123421 http.c:715              => Send header: POST /kyanny/hello/git-upload-pack HTTP/2
20:37:12.123460 http.c:715              => Send header: Host: github.com
20:37:12.123468 http.c:715              => Send header: User-Agent: git/2.32.0
20:37:12.123474 http.c:715              => Send header: Accept-Encoding: deflate, gzip
20:37:12.123483 http.c:715              => Send header: Content-Type: application/x-git-upload-pack-request
20:37:12.123492 http.c:715              => Send header: Accept: application/x-git-upload-pack-result
20:37:12.123511 http.c:715              => Send header: Git-Protocol: version=2
20:37:12.123581 http.c:715              => Send header: Content-Length: 164
20:37:12.123596 http.c:715              => Send header:
20:37:12.123634 http.c:756              == Info: We are completely uploaded and fine
20:37:12.315219 http.c:703              <= Recv header, 0000000013 bytes (0x0000000d)
20:37:12.315310 http.c:715              <= Recv header: HTTP/2 200
20:37:12.315328 http.c:703              <= Recv header, 0000000026 bytes (0x0000001a)
20:37:12.315340 http.c:715              <= Recv header: server: GitHub Babel 2.0
20:37:12.315353 http.c:703              <= Recv header, 0000000052 bytes (0x00000034)
20:37:12.315364 http.c:715              <= Recv header: content-type: application/x-git-upload-pack-result
20:37:12.315375 http.c:703              <= Recv header, 0000000054 bytes (0x00000036)
20:37:12.315387 http.c:715              <= Recv header: content-security-policy: default-src 'none'; sandbox
20:37:12.315398 http.c:703              <= Recv header, 0000000040 bytes (0x00000028)
20:37:12.315408 http.c:715              <= Recv header: expires: Fri, 01 Jan 1980 00:00:00 GMT
20:37:12.315422 http.c:703              <= Recv header, 0000000018 bytes (0x00000012)
20:37:12.315434 http.c:715              <= Recv header: pragma: no-cache
20:37:12.315448 http.c:703              <= Recv header, 0000000053 bytes (0x00000035)
20:37:12.315461 http.c:715              <= Recv header: cache-control: no-cache, max-age=0, must-revalidate
20:37:12.315476 http.c:703              <= Recv header, 0000000023 bytes (0x00000017)
20:37:12.315487 http.c:715              <= Recv header: vary: Accept-Encoding
20:37:12.315500 http.c:703              <= Recv header, 0000000023 bytes (0x00000017)
20:37:12.315512 http.c:715              <= Recv header: x-frame-options: DENY
20:37:12.315524 http.c:703              <= Recv header, 0000000057 bytes (0x00000039)
20:37:12.315537 http.c:715              <= Recv header: x-github-request-id: E57F:0758:10C1225:13B9041:6130B767
20:37:12.315549 http.c:703              <= Recv header, 0000000002 bytes (0x00000002)
20:37:12.315561 http.c:715              <= Recv header:
20:37:12.317253 http.c:756              == Info: Connection #0 to host github.com left intact
20:37:12.320097 http.c:756              == Info: Couldn't find host github.com in the .netrc file; using defaults
20:37:12.320124 http.c:756              == Info: Found bundle for host github.com: 0x7fa69fd046b0 [can multiplex]
20:37:12.320146 http.c:756              == Info: Re-using existing connection! (#0) with host github.com
20:37:12.320161 http.c:756              == Info: Connected to github.com (13.114.40.48) port 443 (#0)
20:37:12.320187 http.c:756              == Info: Using Stream ID: 5 (easy handle 0x7fa6b002c400)
20:37:12.320242 http.c:703              => Send header, 0000000264 bytes (0x00000108)
20:37:12.320254 http.c:715              => Send header: POST /kyanny/hello/git-upload-pack HTTP/2
20:37:12.320260 http.c:715              => Send header: Host: github.com
20:37:12.320266 http.c:715              => Send header: User-Agent: git/2.32.0
20:37:12.320272 http.c:715              => Send header: Accept-Encoding: deflate, gzip
20:37:12.320278 http.c:715              => Send header: Content-Type: application/x-git-upload-pack-request
20:37:12.320284 http.c:715              => Send header: Accept: application/x-git-upload-pack-result
20:37:12.320291 http.c:715              => Send header: Git-Protocol: version=2
20:37:12.320296 http.c:715              => Send header: Content-Length: 252
20:37:12.320302 http.c:715              => Send header:
20:37:12.320333 http.c:756              == Info: We are completely uploaded and fine
20:37:12.514738 http.c:703              <= Recv header, 0000000013 bytes (0x0000000d)
20:37:12.514809 http.c:715              <= Recv header: HTTP/2 200
20:37:12.514824 http.c:703              <= Recv header, 0000000026 bytes (0x0000001a)
20:37:12.514835 http.c:715              <= Recv header: server: GitHub Babel 2.0
20:37:12.514845 http.c:703              <= Recv header, 0000000052 bytes (0x00000034)
20:37:12.514854 http.c:715              <= Recv header: content-type: application/x-git-upload-pack-result
20:37:12.514864 http.c:703              <= Recv header, 0000000054 bytes (0x00000036)
20:37:12.514874 http.c:715              <= Recv header: content-security-policy: default-src 'none'; sandbox
20:37:12.514885 http.c:703              <= Recv header, 0000000040 bytes (0x00000028)
20:37:12.514900 http.c:715              <= Recv header: expires: Fri, 01 Jan 1980 00:00:00 GMT
20:37:12.514913 http.c:703              <= Recv header, 0000000018 bytes (0x00000012)
20:37:12.514927 http.c:715              <= Recv header: pragma: no-cache
20:37:12.514943 http.c:703              <= Recv header, 0000000053 bytes (0x00000035)
20:37:12.514957 http.c:715              <= Recv header: cache-control: no-cache, max-age=0, must-revalidate
20:37:12.514970 http.c:703              <= Recv header, 0000000023 bytes (0x00000017)
20:37:12.514987 http.c:715              <= Recv header: vary: Accept-Encoding
20:37:12.515004 http.c:703              <= Recv header, 0000000023 bytes (0x00000017)
20:37:12.515019 http.c:715              <= Recv header: x-frame-options: DENY
20:37:12.515035 http.c:703              <= Recv header, 0000000057 bytes (0x00000039)
20:37:12.515051 http.c:715              <= Recv header: x-github-request-id: E57F:0758:10C1236:13B9057:6130B768
20:37:12.515069 http.c:703              <= Recv header, 0000000002 bytes (0x00000002)
20:37:12.515105 http.c:715              <= Recv header:
20:37:12.518858 run-command.c:667       trace: run_command: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 7182 on KensukenoMacBook-Pro.local' --check-self-contained-and-connected
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
20:37:12.523223 http.c:756              == Info: Connection #0 to host github.com left intact
20:37:12.525878 git.c:455               trace: built-in: git index-pack --stdin -v --fix-thin '--keep=fetch-pack 7182 on KensukenoMacBook-Pro.local' --check-self-contained-and-connected
Receiving objects: 100% (6/6), done.
* Closing connection 0
20:37:12.534118 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs '--progress=Checking connectivity'
20:37:12.540699 git.c:455               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs '--progress=Checking connectivity'

Ubuntu 20.04.3 LTS 上の git 2.25.1 では以下のような出力になる。

$ GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone https://github.com/kyanny/hello
11:39:28.466447 git.c:439               trace: built-in: git clone https://github.com/kyanny/hello
Cloning into 'hello'...
11:39:28.468728 run-command.c:663       trace: run_command: git-remote-https origin https://github.com/kyanny/hello
* Couldn't find host github.com in the .netrc file; using defaults
*   Trying 52.192.72.89:443...
* TCP_NODELAY set
* Connected to github.com (52.192.72.89) port 443 (#0)
* found 387 certificates in /etc/ssl/certs
* ALPN, offering h2
* ALPN, offering http/1.1
* SSL connection using TLS1.3 / ECDHE_RSA_AES_128_GCM_SHA256
*    server certificate verification OK
*    server certificate status verification SKIPPED
*    common name: github.com (matched)
*    server certificate expiration date OK
*    server certificate activation date OK
*    certificate public key: EC/ECDSA
*    certificate version: #3
*    subject: C=US,ST=California,L=San Francisco,O=GitHub\, Inc.,CN=github.com
*    start date: Thu, 25 Mar 2021 00:00:00 GMT
*    expire date: Wed, 30 Mar 2022 23:59:59 GMT
*    issuer: C=US,O=DigiCert\, Inc.,CN=DigiCert High Assurance TLS Hybrid ECC SHA256 2020 CA1
* ALPN, server accepted to use h2
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x561fca1e18c0)
> GET /kyanny/hello/info/refs?service=git-upload-pack HTTP/2
Host: github.com
user-agent: git/2.25.1
accept: */*
accept-encoding: deflate, gzip, br
accept-language: C, *;q=0.9
pragma: no-cache

* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 200
< server: GitHub Babel 2.0
< content-type: application/x-git-upload-pack-advertisement
< content-security-policy: default-src 'none'; sandbox
< expires: Fri, 01 Jan 1980 00:00:00 GMT
< pragma: no-cache
< cache-control: no-cache, max-age=0, must-revalidate
< vary: Accept-Encoding
< x-frame-options: DENY
< x-github-request-id: E596:70D6:630C58:71FFF2:6130B7F1
<
* Connection #0 to host github.com left intact
11:39:28.735999 run-command.c:663       trace: run_command: git fetch-pack --stateless-rpc --stdin --lock-pack --thin --check-self-contained-and-connected --cloning https://github.com/kyanny/hello/
11:39:28.737966 git.c:439               trace: built-in: git fetch-pack --stateless-rpc --stdin --lock-pack --thin --check-self-contained-and-connected --cloning https://github.com/kyanny/hello/
* Couldn't find host github.com in the .netrc file; using defaults
* Found bundle for host github.com: 0x561fca1e7bf0 [can multiplex]
* Re-using existing connection! (#0) with host github.com
* Connected to github.com (52.192.72.89) port 443 (#0)
* Using Stream ID: 3 (easy handle 0x561fca1e18c0)
> POST /kyanny/hello/git-upload-pack HTTP/2
Host: github.com
user-agent: git/2.25.1
accept-encoding: deflate, gzip, br
content-type: application/x-git-upload-pack-request
accept: application/x-git-upload-pack-result
content-length: 215

* We are completely uploaded and fine
< HTTP/2 200
< server: GitHub Babel 2.0
< content-type: application/x-git-upload-pack-result
< content-security-policy: default-src 'none'; sandbox
< expires: Fri, 01 Jan 1980 00:00:00 GMT
< pragma: no-cache
< cache-control: no-cache, max-age=0, must-revalidate
< vary: Accept-Encoding
< x-frame-options: DENY
< x-github-request-id: E596:70D6:630C64:71FFF9:6130B7F1
<
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
* 11:39:28.947007 run-command.c:663       trace: run_command: git unpack-objects --pack_header=2,6
Connection #0 to host github.com left intact
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
11:39:28.948537 git.c:439               trace: built-in: git unpack-objects --pack_header=2,6
Unpacking objects: 100% (6/6), 1.18 KiB | 1.18 MiB/s, done.
11:39:28.950322 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs '--progress=Checking connectivity'
11:39:28.951430 git.c:439               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs '--progress=Checking connectivity'

この差がプラットフォームの違いによるものなのか、Git クライアントのバージョンによるものなのかは調べていないが、Ubuntu で実行した時のログは curl -v の出力そのものなのに対して macOS 上で実行した時のログには http.c と出ているので、Git の新しめのバージョンから自前実装した HTTP クライアントを内蔵してそちらを使うようになった、とかかもしれない(以前は curl/libcurl を使っていた?)

Git リポジトリと通信する際にどの認証情報を使っているか確認する

git credential fill コマンドで確認できる。

git config - List git credentials from credential helper - Stack Overflow

git credential fill を実行すると入力待ちになるので、以下の二行を入力して、さらに空行を入力する(値は適切なものに変えること)。

protocol=https
host=github.com

空行を認識しない端末の場合(Windows の Git Bash とか)、ヒアドキュメントを使う。この場合、最後の空行はあってもなくても動作するっぽい。

git credential fill <<EOS
protocol=https
host=github.com

EOS

この例では、github.com 上の Git リポジトリと通信する際に使っている認証情報が表示される。

❯ git credential fill
protocol=https
host=github.com

protocol=https
host=github.com
username=kyanny
password=****************

xref: Git: how to retrieve credentials with Git Credential Manager - @kyanny's blog

Maven: artifactId に大文字は使えない

Maven – Guide to Naming Conventions

artifactId is the name of the jar without version. If you created it, then you can choose whatever name you want with lowercase letters and no strange symbols. If it's a third party jar, you have to take the name of the jar as it's distributed. eg. maven, commons-math

逆にいうと upper case letters は使えない。

pom.xml で大文字を含む artifactId が指定されてる場合、jar ファイルをアップロードする maven リポジトリによっては 422 Unprocessable Entity エラーになることがある。


GitHub Packages の Apache Maven レジストリで実験する。なお作業は Ubuntu 20.04.3 LTS 上で行った。

Maven – Maven in 5 Minutes の手順に従って maven パッケージを作る。ただし、わざと artifactId に大文字アルファベットを含める。

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=myApp -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

GitHub Packages の Apache Maven レジストリ の例の通り ~/.m2/settings.xml を作る。

mkdir -p ~/.m2/
cat <<EOM> ~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <activeProfiles>
    <activeProfile>github</activeProfile>
  </activeProfiles>

  <profiles>
    <profile>
      <id>github</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
        </repository>
        <repository>
          <id>github</id>
          <url>https://maven.pkg.github.com/OWNER/*</url>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <servers>
    <server>
      <id>github</id>
      <username>USERNAME</username>
      <password>TOKEN</password>
    </server>
  </servers>
</settings>
EOM
sed -i 's/OWNER/kyanny/' ~/.m2/settings.xml
sed -i 's/USERNAME/kyanny/' ~/.m2/settings.xml
sed -i "s/TOKEN/$GITHUB_TOKEN/" ~/.m2/settings.xml

あらかじめコマンドを実行するシェル上で export GITHUB_TOKEN=XXXX という感じで GitHub の Personal Access Token をセットしておくこと。

pom.xml に < distributionManagement> タグを追記するのがならわしのようだが、-D コマンドラインオプションで指定することも可能。どのようなオプションを指定すればよいかは Apache Maven Deploy Plugin – deploy:deploy に書いてある。

<distributionManagement> のコマンドライン指定用プロパティ名は altDeploymentRepository で、-D オプションで指定する際のフォーマットは id::layout::url とのこと。

ここで id は settings.xml の <server> タグの中に書いたもの・・だと思う。

id The id can be used to pick up the correct credentials from the settings.xml url The location of the repository

とあるので。ここでは https://github.com/kyanny/hello リポジトリに対してパッケージのアップロードを試みるので、url はこのリポジトリの URL になる。

ドキュメントには、

Note: Since 3.0.0 the layout part has been removed.

とも書いてあり、id::url という書式に変更になったのかと思ったが、-DaltDeploymentRepository=github::https://github.com/kyanny/hello と指定したらエラーになった。

Mavenめも - するめとめがね によると、

レイアウトは3.xと2.xの場合はdefault、1.xはlegacyを指定すればいいっぽい?

とのことで、-DaltDeploymentRepository=github::default::https://github.com/kyanny/hello としたらうまくいった。

-l はログをファイルに書き込むオプション。標準出力に出るログはデフォルトで色がついてて見やすいが、-l オプションで出力すると色がつかないので、ファイルにエスケープシーケンスが混じらない。

mvn deploy -DaltDeploymentRepository=github::default::https://github.com/kyanny/hello -l deploy.log

しかしこれは 422 Unprocessable Entity エラーで失敗する。が、それは再現実験が成功したということなので想定内。

deploy.log · GitHub

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project myApp: Failed to deploy artifacts: Could not transfer artifact com.mycompany.app:myApp:jar:1.0-20210903.175557-1 from/to github (https://github.com/kyanny/hello): Transfer failed for https://github.com/kyanny/hello/com/mycompany/app/myApp/1.0-SNAPSHOT/myApp-1.0-20210903.175557-1.jar 422 Unprocessable Entity -> [Help 1]

Maven: mvn deploy の詳細なログを出力する - @kyanny's blog に書いたとおり、-Dorg.slf4j.simpleLogger.log.org.apache.maven.wagon.providers.http.httpclient.wire=trace オプションをつけると 422 Unprocessable Entity エラーの原因がわかる。残念ながら -e オプションや -X オプションでは、ログ出力は増えるものの、このケースの解決のためには足りない。

mvn deploy -DaltDeploymentRepository=github::default::https://github.com/kyanny/hello -Dorg.slf4j.simpleLogger.log.org.apache.maven.wagon.providers.http.httpclient.wire=trace -l deploy.log

...と、ここで本当は 422 Unprocessable Entity のレスポンスボディに「artifactId に upper case letter は使えない」というドンピシャのメッセージが書いてある、という想定だったのだが、そうならなかった。残念。

Maven: mvn deploy の詳細なログを出力する

  1. -e オプションをつける。エラーログがちょっと出る。
  2. -X オプションをつける。DEBUG ログが出るが HTTP のログは出ない。
  3. -Dorg.slf4j.simpleLogger.log.org.apache.maven.wagon.providers.http.httpclient.wire=trace オプションをつける。HTTP リクエスト・レスポンスの中身まで全部出る。

jar ファイルをアップロードする場合、-D のログにはバイナリデータの 16 進数表記のデータが大量に出て読みづらい。その場合は grep -v '\[0x' logfile でフィルタすると見やすくなる。

-e-X の出典は Maven Logging Options | Baeldung

mvn deploy がエラー終了したのログにも出てくる。

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

-D で指定するやつの出典は見失ってしまった・・。少なくとも 422 Unprocessable Entity maven ERROR - GitHub Packages - GitHub Support Community で言及されてるのは発見した。他にも指定方法がありそう。

Bizmates Program: Level 2 Rank B Lesson 8: Complaining to your colleague

温和な元プログラマーの男性トレーナーと。このレッスンも実際は Lesson 7 の Try と Act が中心で、表題の Lesson 8 は導入部しかやらなかった。

Try パートの「あなたの会社の新人がよくやらかすミスは?」には、「会社のアカウントの二要素認証に YubiKey を使うのだが、YubiKey を(PC から抜くときなどに)うっかり触ってしまってランダムな認証用の文字列を Slack チャンネルに投稿してしまう人が後を絶たない、無害なのだが Hubot が即検知して「その認証コードを無効化しました」と投稿するので(千人以上いるチャンネルとかでも)鬱陶しいしちょっと恥ずかしい思いをする」という、だいぶ込み入ったシナリオを話したのだが、さすが元プログラマー、この手のデバイスも使ったことがあるとかでだいぶスムーズに話が進んだ。これが他の女性トレーナーとか相手だったらだいぶ苦労したと思う。

  • At first, I didn't understand why this device still works after disabling the push button.
  • May I help you with that.
  • May I help you with that problem.
  • I'm glad to help you with that.
  • Please click the week column in the calendar.
  • The woman felt bad after hearing some careless and offensive words.

Lesson 8 は「同僚に苦情を言う」という、かなり難しいテーマ。うまくやれるだろうか。