Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Stash SSH Clone Links No Longer Exposed

Josh Wheeler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2015

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.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Josh Wheeler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2015

@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!

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2015

No problem. I'm not in that timezone, believe me ;-)

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2015

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...?

TAGS
AUG Leaders

Atlassian Community Events