We just upgraded from Stash 3.7.1 to Stash 3.11.1. We've been grabbing the ssh link via the following code:
Set<NamedLink> cloneUrls = repositoryService.getCloneLinks(new RepositoryCloneLinksRequest.Builder().repository(repository).user(null).build());
The breakpoint output returns a Set of size 1 with the following being the only entry (IntelliJ):
SimpleNamedLink{href='http://localhost:7990/stash/scm/project_1/josh-test-rep_1.git', name='http'}
I'm not sure what changed between releases but I can't find another way to grab the ssh link other than building it yourself. What am I missing? I'll be patching this issue in an internal plugin tonight as we're performing a large update, but I'm rather frustrated that I can't find a documented reason as to why this is failing nor a solution. Please respond.
Community moderators have prevented the ability to post new answers.
@Jamie Echlin [Adaptavist], the original builder I was using was:
Set<NamedLink> cloneUrls = repositoryService.getCloneLinks(new RepositoryCloneLinksRequest.Builder().repository(repository).user(null).protocol("ssh").build());
This was taken from an answer on the same topic.
I updated my code to read:
Set<NamedLink> cloneUrls = repositoryService.getCloneLinks(new RepositoryCloneLinksRequest.Builder().repository(repository).user(userService.getUserByName("admin")).protocol("ssh").build());
and it works like a charm! I'm not sure I appreciate the way Atlassian handled the change, but I very much appreciate your answer! (especially at 2:00 am MST).
Thanks!
No problem. I'm not in that timezone, believe me ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm pretty sure it will only give you the ssh link if the user has an ssh key set up... if you're using a null user then that wouldn't be the case. That seems consistent with the UI too.
Also try adding .protocol("ssh") to your builder...?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.