JIRA issue links should not use the API URL if it is separately defined
Summary
When specifying different domains for Jira API URL
and Web URL
during , the frontend links on the JIRA Issues
page of a project use the API URL to link to the issues, which does not work.
Some customers utilize a different API URL (domain) to connect to JIRA, while accessing JIRA frontend on another domain. This was formally introduced as a supported configuration in the long past via gitlab-foss#31448 (closed) and gitlab-foss!11707 (merged), so this behavior could be considered a ~bug.
The impact of this makes the JIRA issues links unusable after the integration is successfully setup.
Steps to reproduce
Not trivial, unless within context of an integration/unit test case:
- Setup the JIRA to serve API over one domain, and frontend over another
- Specify both domains in the configuration instructions at https://docs.gitlab.com/ee/user/project/integrations/jira.html#configure-gitlab
- Visit the JIRA Issues section of the project
- Inspect any JIRA Issue link
Example Project
Do not have access to a JIRA account to setup one, currently
What is the current bug behavior?
Links to JIRA issues use the API URL domain name as their base.
What is the expected correct behavior?
Links to JIRA issues should use the Web URL domain name as their base.
Relevant logs and/or screenshots
Some are available on the reporting Customer's ticket (internal link)
The customer's specific setup prohibits direct API access on the web URLs, for security and rate-limiting purposes.
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
Reported over version 13.7.5, but problem continues to exist on master, see investigation below.
Results of GitLab application Check
Expand for output related to the GitLab application check
Not required. Issue can reproduce on GitLab.com too, see investigation below.
Possible fixes
The underlying issue comes from the frontend JIRA Issue Entity serializer relying manually on the JIRA client definition to retrieve the base URL, instead of using some of the nicer methods that build the issue links correctly: https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/serializers/integrations/jira/issue_entity.rb#L60-95
The JIRA client naturally favors the API URL over the Web one: https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/project_services/jira_service.rb#L435-437 and https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/project_services/jira_service.rb#L81-95
Maybe the frontend related bits need to be using a method that will favor the Web URL over the API one: https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/project_services/jira_service.rb#L137-139