nbedos/cistern

unknown repository url with GitLab ssh access

simplelife2010 opened this issue · 8 comments

Hi,

this is an awesome tool. Please carry on.

I am in a GitLab repository with a remote like 'git@ssh.git.tech.blah.db.de:mygroup/myproject.git'.
When running cistern master or sth. similar, I get a
'cistern: unknown repository url'

When I use -r to explicitly use the https url, cistern will work correctly.

I am obliged to use the ssh url when working with GitLab.

Thanks for reporting this.

It could be that the host part of the SSH URL does not match the host part of the URL declared in the configuration file.

For example if the configuration file contains the following section and the SSH URL is git@ssh.my.instance.com:mygroup/myproject.git then it won't work because ssh.my.instance.com is different from my.instance.com.

[[providers.gitlab]]
url = "https://my.instance.com"
token = "..."

What does the URL declared in your config file look like compared to the SSH URL?

this is an awesome tool. Please carry on.

Thanks!

According to the documentation, GitLab allows setting ssh_host in config/gitlab.yml to specify a custom host for SSH connections. So (if this is indeed the cause of the problem) it would make sense to have a similar configuration option in cistern for cases where SSH and HTTP connections are handled by different hosts.

This seems to be the case for my company's gitlab server. The url for ssh connections has the ssh prepended to the https url.
When I change the url in the cistern.toml, cistern starts, but no pipelines are visible. Apparently it is not able to connect to the api.

I made changes on the following branch that should fix this issue: https://github.com/nbedos/cistern/tree/bugfix/gitlab_ssh_host

You can now specify the custom SSH host in the configuration file.

For example, with the following configuration, cistern will know that the GitLab instance can handle repositories hosted on gitlab.example.com and ssh.gitlab.example.com.

[[providers.gitlab]]
url = "https://gitlab.example.com"
ssh-host = "ssh.gitlab.example.com"   # Note that this is a hostname, not a URL

The ssh-host key is documented in the sample configuration file:

# Custom SSH host (optional, string). If this GitLab instance uses a custom host for SSH
# connections, uncomment the following line and specify the hostname so that cistern knows
# to associate repositories on the host to this instance.
# ssh-host = "ssh.gitlab.example.com"

Could you please test these changes to see if it fixes the issue? I do not have access to a GitLab instance with a custom SSH host so I can test the fix myself. If you cannot build cistern from source just let me know and I'll make a pre-release containing pre-built binaries.

I will try to build it. Two questions:

  1. I have not seen any special advice on building on macOS. Do I just build as if I was working on Linux?
  2. Regarding releases of cistern: I have not seen macOS binaries. What is the preferred way to install a binary release on macOS? Up to now I had used conda, which works fine but I don't know if the conda-forge is maintained regularly to provide up-to-date cistern releases.

Well, after brew installing go and pandoc, everything went smooth.

The issue is gone, thanks for the quick help!

1. I have not seen any special advice on building on macOS. Do I just build as if I was working on Linux?

Yes, the instruction given in README.md are for "UNIX systems" and that includes macOS.

2. Regarding releases of cistern: I have not seen macOS binaries.

The release archives for macOS are named x.x.x-darwin-amd64.tar.gz. "darwin" is the name used by the go compiler to refer to macOS.

Well, after brew installing go and pandoc, everything went smooth.

The issue is gone, thanks for the quick help!

Great, thanks!