Gitlab Jira integration not working

We have a self-hosted jira instance and I am trying to connect gitlab to it using a Jira API token. Every time I test the connection I get “connection failed”.

The gitlab jira configuration fields include a Jira API URL of
https://<jira base url>/rest/api/latest/

My integration_json.log shows:

"severity":"ERROR",
   "time":"2022-03-24T17:35:25.129Z",
   "correlation_id":"01FYYFYNS00PW9VNA1W7842MBJ",
   "service_class":"Integrations::Jira",
   "project_id":2020,
   "project_path":"testgroup6/archietest6",
   "message":"Error sending message",
   "client_url":"https://<jira base url>/rest/api/latest",
   "exception.class":"JIRA::HTTPError",

Strangely enough, the jira logs show a failed incoming api connection as:

"GET /rest/api/latest/rest/api/2/serverInfo- HTTP/1.1" 401 23513 471 "-" "-" "u76339"

Notice that the jira logs show that the /rest/api section of the url gets doubled as /rest/api/latest/rest/api/2

I don’t know why gitlab is doing that.

When I manually curl the same url that gitlab is hitting but without the incorrect url addition as
curl -H "Authorization: Bearer <token>" https://<jira base url>/rest/api/2/serverInfo
, I get a successful connection with a Jira log entry of
"GET /rest/api/latest/serverInfo HTTP/1.1" 200

Is this a bug or am I doing something wrong?

Hi @wonkaba

please follow official documentation how to setup Jira integration. You can see on that page, that in your case Jira API URL should be https://<jira base url> or left blank to use the Web URL

Thank you very much @balonik for the quick reply. Yes, that was an issue which I have fixed. Although still not working I’m pretty sure that it is due to me using a Jira API token to connect to my Jira Server instance. Am I reading the documentation correctly that gitlab jira integration doesn’t work with jira api tokens when connecting to Jira Server deployments? And if so, why not? I am able to curl using the token without issues. Is this something that needs to be requested in a feature request?

It works only using username/password. Since Jira Server (not the Data Center edition) is discontinued I doubt any new features will be implemented. Both Atlassian and GitLab are pushing cloud offerings over on-prem solutions.

But this has to be a GitLabControl issue. Like I said, Jira sever does have API tokens and I can curl Jira server and get data from the API so that tells me that gitlab’s jira integration just needs to modify the call syntax when user is using a token over a password.

@wonkaba from the link @balonik provided: Configure the Jira integration in GitLab | GitLab

it’s clearly written what is required. Now, also lower down in the docs (point 7):

I would suggest, and guess, that when you created the API token you were logged in as a particular user correct? Therefore, you could try using username that you were logged into Jira as when you created the API token, and use the token in the password field and see if that works.

The docs seem to show that token support is for use with the cloud version of Jira, but even with that it still needs to have an email address to be supplied in the username field. So just try with a Jira username and token and see if it works.

Otherwise, check the Gitlab issues here: Issues · GitLab.org / GitLab · GitLab and see if someone already opened an issue for adding token support for Jira server. And if not, open an issue as that is the only way features will be added and supported. If there is a reason why the Gitlab docs specifically say to user username/password, then that is how it should be used. But that doesn’t stop you experimenting to try using username/token. Otherwise, simply create a user with limited access to your Jira server, and use that login/password to integrate with Gitlab.

Thanks. Yeah, I saw that in the docs which is what made me realize it in the first place. I just don’t think this is a jira issue. I think that GitLab just isn’t utilizing the token support jira had in jira server. My plan is to submit a ticket if one doesn’t exist. Thanks for the help.

Curious if you ever got this sorted out or have a ticket submitted. I am running into the same issue.

Yes, issue here