New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gitlab credential issues. Git clone container throws error. #1223
Comments
|
@bobbarebygg any news on this? I'm having the same issue. |
|
@AKoetsier are you using I'm probably going to alter GitLab to default to |
|
also make sure your GitLab instance is capable of cloning with a token and git+http(s). We use a netrc file to clone private repositories to inject the username and password: Also, if you are using a self-signed certificate, make sure you configure |
|
@bradrydzewski I was not using the oauth-setting but the default (token). I did not set anything in gitlab (apart from the defaults) to be able to clone using a token so I will take another look into that. Tnx for the quick response! |
|
No clear news, no. I tried a fresh installation (8.0.4.) in hope of the error occured when upgraded from 7.x.x to 8.0.x. The oauth is working for me. The problem is to clone repos with git. We are currently testing out GOGS to see if it can replace gitlab. It is really fast and feels solid, but it doesn't solve the problem. |
|
Gitlab use and some uri paths routed to different upstream |
|
i have the same issue with gitlab 8.0.1. |
|
@davidak Did you try |
|
@Bugagazavr yes, it helps with the self-signed certificate. |
|
Did anyone find a solution to this problem? I'm currently having the same issue and I have tried the clone_mode=oauth but not success. It looks like drone needs it's own login for Gitlab? Anything would be greatly appreciated. |
|
@blandes what gitlab version do you have? i havn't found the time to update, that might help. |
|
@davidak So I'm actually using Rancher to deploy my CI (which may be the problem) so the version is rancher/drone:0.4 |
|
@blandes what gitlab version? |
|
@davidak drone/drone:0.4 |
|
@blandes gitlab not drone. |
|
@davidak Sorry, I wasn't paying attention. gitlab:8.4.4 |
|
Okay, that is the newest version. Then updating gitlab also don't help. :/ Someone has to debug this. |
|
Yeah, it's been stressing me out too much. Iv'e tried so many things such as deployment keys, tokens, oauth, and so on. I was thinking possibly a port issue because of the git+http but no dice. Thanks for the help. |
|
@blandes do you have self signed certificate? |
|
@Bugagazavr No |
|
So Gitlab is connected to Drone and is showing repos, builds, and so on. When a build is triggered or a commit is made Drone then spits out the original error at the top. I'm not sure where the .netrc is so I haven't tried that option yet. I did however note that when I had a co-worker clone the repo from his computer that he had to login. I haven't set up his ssh key yet but the permission looked the same as above. Could I possibly make a user for drone? |
|
Drone clones the repository using the git+http(s) url and automatically authenticates with a token, or if you use |
|
@blandes @blandes @davidak if you can help me:
|
|
@Bugagazavr 1. No 2. self signed 3. how should the command get executed if the repo is not cloned? |
|
@davidak sorry, you can create netrc file manually your_drone_repo_token you can get from gitlab in drone service settings |
|
@davidak if you are using a self-signed certificate you might need to configure your yaml to clone the repository and ignore tls verification: this executes |
|
@bradrydzewski I think this is only certificates problem:
@blandes can you try add this to your clone:
skip_verify: true |
|
@bradrydzewski i have that already. @Bugagazavr it asks for a username like without the .netrc, i have set the right permission. tested on ubuntu 14.04 |
|
@bradrydzewski I have it on my remote config, does this do the same thing? |
|
@davidak When I turn down the settings from Private to Public, it will actually try to pull the repo but does a hard reset? |
|
I set the repo to public and get exactly the same error. As the message "fatal: could not read Username" implies, git tries to read the username (and password) from keyboard input, the .netrc is ignored. |
This is not the same thing. This value in the remote config defines how Drone server interacts with GitLab. The yaml configuration defines how the Git plugin should clone the repository. |
|
I was able to verify that I can clone a repository by configuring the appropriate drone integration for my private gitlab repository (via gitlab repository settings), and then manually invoking the git clone plugin. I don't have a drone+gitlab installation, so I chose to perform this manually: docker run -i plugins/drone-git <<EOF
{
"repo": {
"clone_url": "https://gitlab.com/bradrydzewski/test.git"
},
"build": {
"event": "push",
"branch": "master",
"commit": "636b4f33dbe819f65a06036cfad619afa2812503",
"ref": "refs/heads/master"
},
"workspace": {
"root": "/drone/src",
"path": "/drone/src/gitlab.com/bradrydzewski/test",
"netrc": {
"machine": "gitlab.com",
"user": "XXXXXXXXXXXXX",
"login": "drone-ci-token"
}
}
}
EOFThis results in the following successful output: While it is true I didn't test this wing-to-wing with a full drone+gitlab installation, my understanding is there are individuals successfully using drone+gitlab. This leads me to believe there is no known issues with cloning gitlab repositoires with a netrc. @Bugagazavr can you confirm? Are you still using Drone with GitLab? ** note that the |
|
@bradrydzewski yep it working for me, looks like this depends on certificate. |
|
@bradrydzewski with your code i get:
i tried to put |
|
plugin-specific configuration goes in the docker run -i plugins/drone-git <<EOF
{
"repo": {
"clone_url": "https://gitlab.com/bradrydzewski/test.git"
},
"build": {
"event": "push",
"branch": "master",
"commit": "636b4f33dbe819f65a06036cfad619afa2812503",
"ref": "refs/heads/master"
},
"workspace": {
"root": "/drone/src",
"path": "/drone/src/gitlab.com/bradrydzewski/test",
"netrc": {
"machine": "gitlab.com",
"user": "XXXXXXXXXXXXX",
"login": "drone-ci-token"
}
- }
+ },
+ "vargs": {
+ "skip_verify": true
+ }
}
EOF |
|
thanks. with that the certificate issue is solved, but i get that issue of this ticket:
|
|
@davidak can you clone with
This will help us isolate the problem. I can complete all four of these tasks using gitlab.com. Note that the first three don't even involve drone. So if the first three tasks don't work, perhaps there is something wrong with the gitlab install, given these commands all work with gitlab.com |
|
this is strange: could be this issue https://gitlab.com/gitlab-org/gitlab-ce/issues/2669 |
|
@bradrydzewski I did add the following lines to my .drone.yml but nothing still. Sorry for the long delay. clone: |
|
@blandes @davidak my recommendation is to test this against gitlab.com ... if you can demonstrate the same error with gitlab.com then we know it is a drone error. If you cannot demonstrate with gitlab.com, then we know it is a configuration error, at some level, outside of drone. The fact that I was able to clone from gitlab.com with a netrc and the drone git plugin, and that @Bugagazavr is using drone with omnibus gitlab, leads me to believe this is a configuration error outside of drone. If that is the case, our ability to help troubleshoot will be very limited. |
|
I'm getting the same errors as above on my self-hosted GitLab instance. Screens: |
|
@venoma333 thanks for report Can you provide some drone logs? |
|
I believe these lines are relevant from the logs: This is my .drone.yml: build:
image: node:5.5.0
commands:
- echo "done"The drone server is behind a reverse nginx proxy and this is the nginx config: |
|
@venoma333 this is not a gitlab bug, your yaml is invalid. try to replace |
|
@Bugagazavr I'm really sorry, Not familiar with yaml yet. The private project was pulled, tested and the build was a success. I guess it really is a configuration issue. |
|
Sorry to bring an old issue alive again, but I have a workaround that works for self-hosted GitLab solutions with private repositories. However, be aware that drone should not be in public mode as this will reveal the token used. After activating the repository with GitLab, go into the repository settings in GitLab, then Services, then Drone CI. Copy the token on that page. Now go into the database for Drone and run the following: UPDATE repos SET repo_clone='{scheme}://drone-ci-token:{token}@{gitlab-domain}/{owner}/{project}.git' WHERE repo_id={repo_id};
The downside now is that Drone will show the full clone URL in its output, including the token. This could be a security issue if you aren't careful. The root cause of the problem, in the end, appears to be Drone not attaching the credentials provided for private repositories. It may be beneficial to allow a toggle for private repositories. |
|
@ColtonProvias for private repositories drone adds a netrc file which sets see http://readme.drone.io/setup/remotes/gitlab/#gitlab-options:dd87d86ac28472949397c68a306dd605
I am able to clone private repositories with Drone and GitLab (gitlab.com) without issue |
|
I am using |
Are you sure this is the root cause? the git plugin is responsible for creating the netrc file and the git plugin is agnostic to the service provider (it doesn't know anything about GitHub, GitLab, etc). It creates the netrc for all private repositories, regardless of service provider. We can fully isolate this test by running the git plugin locally. You can get a copy of the git plugin by running I ran the above command and it succeeded with the below output. |
|
If I run the plugins/git image directly in rancher with the appropriate values as you showed, there is no error. However, running it normally via drone produces the following JSON in the build container's command: {
"repo": {
"id": 3,
"owner": "Zeitghost",
"name": "Webmail",
"full_name": "Zeitghost/Webmail",
"avatar_url": "",
"link_url": "https://git.zeitghost.io/Zeitghost/Webmail",
"scm": "",
"clone_url": "http://git.zeitghost.io/Zeitghost/Webmail.git",
"default_branch": "master",
"timeout": 60,
"private": true,
"trusted": false,
"allow_pr": true,
"allow_push": true,
"allow_deploys": true,
"allow_tags": true
},
"build": {
"id": 3,
"number": 1,
"event": "push",
"status": "running",
"enqueued_at": 1461694271,
"created_at": 1461694271,
"started_at": 1461694271,
"finished_at": 0,
"deploy_to": "",
"commit": "ed45a85f463db8647e56b30a8f3f4514add2a421",
"branch": "master",
"ref": "refs/heads/master",
"refspec": "",
"remote": "",
"title": "",
"message": "Update README.md to trigger build",
"timestamp": 0,
"author": "Colton Provias",
"author_avatar": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61.jpg?s=128",
"author_email": "admin@example.com",
"link_url": ""
},
"build_last": {
"id": 0,
"number": 0,
"event": "",
"status": "",
"enqueued_at": 0,
"created_at": 0,
"started_at": 0,
"finished_at": 0,
"deploy_to": "",
"commit": "",
"branch": "",
"ref": "",
"refspec": "",
"remote": "",
"title": "",
"message": "",
"timestamp": 0,
"author": "",
"author_avatar": "",
"author_email": "",
"link_url": ""
},
"job": {
"id": 3,
"number": 1,
"error": "",
"status": "running",
"exit_code": 0,
"enqueued_at": 1461694271,
"started_at": 1461694271,
"finished_at": 0,
"environment": {}
},
"keys": {
"public": "REDACTED",
"private": "REDACTED"
},
"netrc": {
"machine": "git.zeitghost.io:443",
"login": "oauth2",
"user": "REDACTED"
},
"config": "publish:\\n docker:\\n registry: docker.zeitghost.io\\n insecure: true\\n repo: zeitghost/webmail\\n tag: latest\\n username: $$REGISTRY_USERNAME\\n password: $$REGISTRY_PASSWORD\\n email: $$REGISTRY_EMAIL\\n\\ndeploy:\\n rancher:\\n url: http://rancher.zeitghost.io/v1/projects/1a5\\n access_key: $$RANCHER_ACCESS\\n secret_key: $$RANCHER_SECRET\\n service: mail/webmail\\n docker_image: docker.zeitghost.io/zeitghost/webmail:latest\\n start_first: true\\n confirm: true\\n timeout: 300\\n\\nnotify:\\n slack:\\n channel: development\\n webhook_url: $$SLACK_WEBHOOK",
"secret": "",
"system": {
"version": "",
"link_url": "http://drone:8000",
"plugins": [
""
],
"globals": [
""
],
"privileged_plugins": [
""
]
}
}The link_url is The docker-compose.yml for my Drone CI service is as follows: drone:
environment:
REMOTE_DRIVER: gitlab
REMOTE_CONFIG: https://git.zeitghost.io:443?client_id=REDACTED&client_secret=REDACTED&skip_verify=true&clone_mode=oauth
DATABASE_DRIVER: postgres
DATABASE_CONFIG: postgres://REDACTED:REDACTED@postgres:5432/drone?sslmode=disable
log_driver: ''
labels:
io.rancher.container.pull_image: always
tty: true
log_opt: {}
image: drone/drone:latest
links:
- 'postgres:'
volumes:
- drone-data:/var/lib/drone
- /var/run/docker.sock:/var/run/docker.sock
stdin_open: true
volume_driver: convoy-gluster
postgres:
environment:
POSTGRES_PASSWORD: REDACTED
POSTGRES_USER: REDACTED
POSTGRES_DB: drone
log_driver: ''
labels:
io.rancher.container.pull_image: always
tty: true
log_opt: {}
image: postgres:9.5.2
volumes:
- drone-db:/var/lib/postgresql/data
stdin_open: true
volume_driver: convoy-gluster |
|
I am guessing the issue is the port included in the machine: "netrc": {
- "machine": "git.zeitghost.io:443",
+ "machine": "git.zeitghost.io",
"login": "oauth2",
"user": "REDACTED"
},I would expect the 443 to be implicit when using https. Perhaps when you setup drone you should omit 443 from the configuration? This would prevent it from being included in the netrc. Reference https://github.com/drone/drone/blob/master/remote/gitlab/gitlab.go#L287 |
|
That was the issue. Thanks! I added the :443 in as the documentation at http://readme.drone.io/setup/remotes/gitlab/#gitlab-configuration:dd87d86ac28472949397c68a306dd605 stated that it defaults to :80 otherwise. That fixed the issue. |
|
Thanks, we can get that fixed in the docs. We also added code to the Gogs implementation to strip the port, which probably makes sense for GitLab as well https://github.com/drone/drone/blob/master/remote/gogs/gogs.go#L178 I'll make those changes for good measure and then we can close this issue. |
|
I'm closing this issue because we have now verified with multiple GitLab installs that Drone is able to clone public and private repositories when correctly configured. I recently patched the issue described above where the netrc was unable to clone private repositories when the gitlab url included port number: #1223 (comment) Note that in addition to my own testing that shows Drone can clone from a properly configured GitLab instance (at GitLab.com) this was also confirmed by @ColtonProvias on his private GitLab instance once we fixed the netrc and port issue: #1223 (comment) So in conclusion, if you are coming to this issue because you think there is a bug with Drone please take a look at your GitLab configuration. Also note that you can test the Git clone capabilities in isolation per this comment: #1223 (comment) |

This a summary of discussions made in Gitter to keep track of progress.
Leave this issue to verified information. Keep the discussion to Gitter
Error:
Within the git plugin container following error is throwed while cloning a repo from gitlab. This error have begun to appear with drone integration with recent versions of GitLab.
Versions:
The error have been reproduced using:
gitlab-8.0.4-0,gitlab-8.0.4-1Anton Ikonovalov cant reproduce this error on version
gitlab-8.0.3-1. Something have probably happen in later version which breaks Drone from working.Older versions of GitLab CE could be found here: https://packages.gitlab.com/gitlab/gitlab-ce
Next step:
clone_mode=oauthin your drone gitlab configuration stringnetrclocally and test it with GitLab.The text was updated successfully, but these errors were encountered: