Search code examples
jiragerrit

gerrit associate Jira issues to Git commits return 401


My gerrit checking Jira connectivity ... [OK] But git push has an error:request failed Please help me. Here are my configurations and operations:

gerrit configurations:

*** Jira connectivity
***

Jira URL (empty to skip)       [http://jira]:
Jira username                  [jiraxx]:
Change jirasa's password       [y/N]?
Connection timeout             [120000 ms]:
Read timeout                   [30000 ms]:
Test connectivity to http://jira/ [y/N]? y
Checking Jira connectivity ... [OK] - Jira Ver8
*** Jira issue-tracking association
***

Jira issue-Id regex            [([A-Z]+-[0-9]+)]:
What html would you like to use? [<a href="http://jira/browse/$1">$1</a>]:
Issue-id enforced in commit message [suggested/?]:

git push:

[root@git]# git add .
[root@git]# git commit -m "TEST-1"
[root@git]# git push origin HEAD:refs/for/master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 341 bytes | 341.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2)
remote: Processing changes: refs: 1, new: 1, done
remote: commit 0779d4a: Failed to check whether or not issue TEST-1 exists, due to connectivity issue. Com             mit will be accepted.
remote: java.io.IOException: Request failed: http://jira/rest/api/2/issue/TEST-1 - 401 - null
remote:
remote: SUCCESS
remote:
remote:   http://gerrit/c/gitrepo/+/18019 TEST-1 [NEW]
remote:
To ssh://gerrit:29418/gitrepo
 * [new branch]      HEAD -> refs/for/master


Solution

  • Since a 401 HTTP error means the client request has not been completed because it lacks valid authentication credentials for the requested resource:

    • either your Jira credentials are not valid (despite the "Checking Jira connectivity" step)
    • or you need to use a proxy to access said Jira, proxy requiring authentication.

    Don't forget those error messages are coming from the remote Gerrit server, meaning that a "Test connectivity to http://jira" done locally would not implies that the remote Gerrit server can do the same.