How do I force gitlab runner to use the host's domain name instead of ip address? - gitlab

My company has a bitnami gitlab installation that we self-host. While I manage the gitlab installation, I am not an expert on it by any stretch. A few months back, I configured a project to use a gitlab runner in order to perform unit tests when the project is committed.
Today, when I pushed a commit, the gitlab runner tried to pull from the ip address using ssl. How do I tell it to pull the commit using the domain name?
I want it to use https://gitlab.ourcompany.com but it is using https://10.1.3.3
NOTE: not our real ip address or host name:
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/full-stack/apigw/.git/
fatal: unable to access 'https://10.1.2.3/full-stack/apigw.git/': SSL: no alternative certificate subject name matches target host name '10.1.2.3'

I found the answer after posting the question. Leaving both here for others.
It turns out that our gitlab.rb config file had the external_url set incorrectly. Here are the steps to change that:
/etc/gitlab/gitlab.rb
# other entries omitted for brevity
# was external_url 'https://10.1.2.3'
external_url 'https://gitlab.ourcompany.com'
Then reload your settings:
sudo gitlab-ctl reconfigure

Related

git clone from internal gitlab repository doesn't work unless I'm running as root

I'm trying to clone an internal gitlab repository, but it keeps giving me this error message
fatal: unable to access 'https://gitlab**************.git/': gnutls_handshake() failed: Error in the pull function.
But somehow, if I'm running as root, the cloning process would run perfectly.
The problem is, I needed this to work because I'm trying to use this repository on Jenkins.
Can someone help me or explain why it only worked if I'm running as root?
root uses the same version of git and curl.
But it does not use the same:
global git config: compare the output of git config --global -l in both instances (root and regular user account).
environment configuration (type env in both cases, and compare the environment variables)
In particular, look for sslcainfo (git config --global -l|grep -i ssl) which could reference the certificate needed to contact through TLS your on-premise HTTPS GitLab URL.

Change SSH repo url in GitLab

I have gitlab on my server. URL, for example: https://git.site.com
On project page I have similar URL for my repo:
How I can change path only for ssh repo path? I need IP address of my server, not URL
Change this in the /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_ssh_host'] = 'gitssh.example.com'
and then run gitlab-ctl reconfigure
You should take a look at external_url configuration field: https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
If you're using Omnibus, you can also custom the SSH host: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L39

How do I start using Gitlab-CI in Gitlab Omnibus edition?

I have installed Gitlab Omnibus gitlab-7.4.3_omnibus.5.1.0.ci-1.el6.x86_64.rpm on CentOS 6.6. I have a few projects created and working fine but I would like to try using the continuous integration features. I don't know where to start and documentation/tutorials are thin on the ground.
I have found the following files that do not appear in an older Gitlab omnibus install I have:
/usr/bin/gitlab-ci-rake
/usr/bin/gitlab-ci-rails
I presume I need to do something with these? But do I need a configuration file first?
In my projects (Settings > Services > Gitlab CI) I can see there are options for Active, Token and Project Url but I do not know what to put in these fields.
Any help to get me started on CI would be appreciated. Cheers,jonny
We recently installed the omnibus GitLab 7.6.2 release which has GitLab CI 5.3 built in. I had the same question. Here's how we got it working.
We're using a single secured server over https; single ip for both gitlab and gitalb-ci hosts.
We have dns entries for both host names to a single ip. (Done with an alias for the ci server I think). We have two ssl certificates one for each hostname.
We have the following lines at the top of the /etc/gitlab/gitlab.rb script (found by searching the gitlab site for rb file setup details):
external_url 'https://gitlab.example.edu'
nginx['redirect_http_to_https'] = true
ci_external_url 'https://gitlab-ci.example.edu'
ci_nginx['redirect_http_to_https'] = true
For http, leave out the nginx statements.
If gitlab-ci url displays the gitlab site contents then the ci_nginx statement needs to be corrected.

Change SSH host for cloning

Is there any way to change default ssh host for gitlab (displayed at top of repository view in web interface)? I mean only for SSH in clone urls.
For example I have my gitlab installation on git.example.com, but example.com also points to the same machine (different site). Can I change ssh clone urls from:
git clone git#git.example.com:user/repository
to:
git clone git#example.com:user/repositiory
but for http and https leave it with git.example.com?
Yes,
If you are using the omnibus package you can edit /etc/gitlab/gitlab.rb and add gitlab_rails['gitlab_ssh_host'] = 'example.host.com'
There is the equivalent option somewhere in gitlab.yml : ssh_host: example.host.com
Yes.
If your subdomain behaves the same way your actual domain does, it should not be a problem. If the subdomain points to the same IP, git or ssh for that matter should not bother.

How to clone a git repository which is present on a remote linux server into windows

I have a git repository setup on a remote server XXX.XXX.XXX.XXX and want to clone the same in my windows environment. It's actually a webapp present under /var/www/html/Testsite. The git repo is created inside the Testsite folder.
I was hoping the command:
git clone http://XXX.XX.XX.XX/Testsite/mysite.git would work fine but it does not. Please let me know how I can get the URL to configure and clone it into my environment.
However, with the local folder, I am easily able to clone the repository which works totally fine.
Thanks a lot.
You can't, without configuring your Apache in order to server git request.
The fact that your mysite.git is within Testsite doesn't make it accessible to git.
As shown in this config, you can define in a separate VirtualHost (so in a separate port, since you are already using port 80/443 on Testing) a config in order to call the git script able to interpret a git clone request:
ScriptAlias /hgit/ /path/to/git/libexec/git-core/git-http-backend/
SetEnv GIT_HTTP_BACKEND "/path/to/git/libexec/git-core/git-http-backend"
<Location /hgit>
...
</Location>
As for ssh, the right url would be:
git clone ssh://account#XX.XX.XX.XX/var/www/html/Testsite/mysite.git
And it would work only if you generate a public and private (non-passhrase protected at first), and publish the public key in the ~account/.ssh/authorized_keys.
Or the sshd (ssh daemon) on the server won't recognize you (hence the password request), and won't know where "Testing/" is.

Resources