Hello there, I have spent about 2 days digging through even the weird corners of the internet to get a picture of what’s going on, so I think I have a pretty good idea about the whole thing now.
I am unable to clone a private repository from gitea, when I set the repository to public, the repository is succesfully cloned.
After all the tests I have run I have a feeling that the login information is not properly passed to plugins/git
The setup
I have tested using drone 0.7, drone 0.8.0-rc.3 and even the latest image.
I have tested using sqlite and postgres db backend
Gitea is at version 1.2.0-rc2, I couldn’t get any previous versions to authenticate succesfully, I think the drone support was added recently?
The settings
As per many other topics here and elsewhere, I have confirmed the following:
- The repository (gitea) was private before I added it and is still private
- Drone settings for the repository are set to private as well - if I set the repository to public and keep drone settings as private, it still clones it succesfully
- The user account that added the repository has not revoked oauth access (can be seen in gitea and I am using the user to login to drone and I am still able to add/remove repositories with said account and I have started from scratch multiple times)
- I am able to clone the repository using a standalone plugins/git image provided I pass in the netrc authentication configuration (either another oAuth token or username/password)
discourse issue?
For some reason I cannot follow a list with codeblock on discourse - it will not format the code block unless I put something between the list and the block.
docker run --rm -i plugins/drone-git <<EOF
{
"repo": {
"clone_url": "https://gitea.my.domain/Org/Repo.git",
"private": true
},
"build": {
"event": "push",
"commit": "77b6f3e3da1cb94eb4ce8b6ce32ea89984a0409a",
"ref": "refs/heads/master"
},
"workspace": {
"root": "/drone/src",
"path": "/drone/src/gitea.my.domain/org/repo",
"netrc": {
"machine": "gitea.my.domain",
"**login**": "{LOGIN REDACTED}",
"**user**": "{PASSWORD/OAUTH_TOKEN REDACTED}"
}
}
}
EOF
Drone Git Plugin built from 43dcd64
$ git init
Initialized empty Git repository in /drone/src/gitea.my.domain/org/repo/.git/
$ git remote add origin https://gitea.my.domain/Org/Repo.git
$ git fetch --no-tags origin +refs/heads/master:
From https://gitea.my.domain/Org/Repo
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
$ git reset --hard -q 77b6f3e3da1cb94eb4ce8b6ce32ea89984a0409a
I was a bit confused with the property naming
This might be a question for @tboerger, the netrc Type is a bit weird in version 0.4 which is using the type from deprecated drone-plugin-go by @bradrydzewski
I have to pass in the username to “login” property, and password/oauth token to “user” property (there might be a different way to pass in oauth, but I haven’t found it
I also get the same result running with env variables
docker run --rm -e DRONE_REMOTE_URL="https://gitea.my.domain/Org/Repo.git" -e DRONE_NETRC_USERNAME="login_redacted" -e DRONE_NETRC_PASSWORD="oauthToken/Password_redacted" -e DRONE_NETRC_MACHINE="gitea.my.domain" -e DRONE_COMMIT_SHA="77b6f3e3da1cb94eb4ce8b6ce32ea89984a0409a" -e DRONE_COMMIT_REF="refs/heads/master" plugins/git
+ git init
Initialized empty Git repository in /.git/
+ git remote add origin https://gitea.my.domain/Org/Repo.git
+ git fetch --no-tags origin +refs/heads/master:
From https://gitea.my.domain/Org/Repo
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
+ git reset --hard -q 77b6f3e3da1cb94eb4ce8b6ce32ea89984a0409a
The drone builds
Anyways, this brings me back to the builds
Repository (gitea): Private
Drone repository setting: Private
Even tried to add secrets for netrc, however they are not passed to the plugin directly without creating my own clone pipeline… I suppose? (tried netrc_username, netrc_password, netrc_machine, drone_netrc_username, drone_netrc_password, drone_netrc_machine)
Resulting log from such a build is
+ git init
Initialized empty Git repository in /drone/src/gitea.my.domain/Org/Repo/.git/
+ git remote add origin https://gitea.my.domain/Org/Repo.git
+ git fetch --no-tags origin +refs/heads/master:
fatal: could not read Username for 'https://gitea.my.domain': No such device or address
exit status 128
This seems to me, that .drone.yml is succesfully fetched from the repository, however the login information is not properly passed to plugins/git? I assumed this because if I improperly format the .drone.yml, I get
Invalid or missing pipeline section
Now when I change the settings to
Repository (gitea): Public
Drone repository settings: Public (same result if this setting is Private)
+ git init
Initialized empty Git repository in /drone/src/gitea.my.domain/Org/Repo/.git/
+ git remote add origin https://gitea.my.domain/Org/Repo.git
+ git fetch --no-tags origin +refs/heads/develop:
From https://gitea.my.domain/Org/Repo
* branch develop -> FETCH_HEAD
* [new branch] develop -> origin/develop
+ git reset --hard -q 1bb52e8a1fd68ad79a7075c46b63c804dc687fd1
+ git submodule update --init --recursive
So this is where I am stuck at the moment, I am more than happy to help with debugging if needed, I am just not sure where to go from here