Skip to content
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

fix(repositoryUrl): on beta repositoryUrl needs auth for pre-release flows #1186

Merged

Conversation

jmodjeski75
Copy link
Contributor

Fixing issue with authentication for repositoryUrl not being used for prerelease workflow

@jmodjeski75 jmodjeski75 changed the title WIP repositoryUrl needs auth for pre-release flows May 20, 2019
@jmodjeski75 jmodjeski75 changed the title repositoryUrl needs auth for pre-release flows fix(repositoryUrl): on beta repositoryUrl needs auth for pre-release flows May 20, 2019
@jmodjeski75
Copy link
Contributor Author

possible fix for #1170 #1156

Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great PR 👍

@gr2m gr2m merged commit 3610422 into semantic-release:beta Jun 5, 2019
@pvdlg
Copy link
Member

pvdlg commented Jun 5, 2019

I'm not sure those changes were necessary. It seems the change is to use the authenticated URL to call git ls-remote. However this command should work without authentication, as the the CI was able to clone the repo.

My understanding is that if git clone works then git ls-remote should work as well.
How come the repo was cloned successfully but the branches couldn't be read on the remote?

@pvdlg
Copy link
Member

pvdlg commented Jun 5, 2019

@gr2m
Copy link
Member

gr2m commented Jun 5, 2019

Let’s revert and then try again

@pvdlg
Copy link
Member

pvdlg commented Jun 5, 2019

The build error happens only on Travis though, not locally.
I'll investigate a bit more and if I can't find a solution I'll revert and work on it later.

@jmodjeski75
Copy link
Contributor Author

jmodjeski75 commented Jun 5, 2019

I'm not sure those changes were necessary. It seems the change is to use the authenticated URL to call git ls-remote. However this command should work without authentication, as the the CI was able to clone the repo.

My understanding is that if git clone works then git ls-remote should work as well.
How come the repo was cloned successfully but the branches couldn't be read on the remote?

@pvdlg
Are you using a private repository? git ls-remote for a private repository requires auth

See: https://git-scm.com/docs/git-ls-remote.html references https://git-scm.com/docs/git-fetch#_git_urls_a_id_urls_a

@pvdlg
Copy link
Member

pvdlg commented Jun 5, 2019

Are you using a private repository? git ls-remote for a private repository requires auth

Yes but that auth should already be provided one way or another by your CI (ssh key or environment variable or other).

How could your CI run git clone otherwise?
What I don’t understand is how git clone could work while git ls-remote doesn't?

@jmodjeski75
Copy link
Contributor Author

git clone <with-auth-url>

@pvdlg
Copy link
Member

pvdlg commented Jun 5, 2019

The git clone is done by your CI way before semantic-release run.

Where does the <with-auth-url> come from? If your CI uses an authenticated URL to clone why doesn't it set that URL in the origin of the repo.
How do you end up in the situation of your CI running git clone <with-auth-url> then setting the non authenticated URL as the origin of the clone?

Before this PR, the git ls-remote was called with origin in order to use whatever remote URL the CI uses which should at least gives read permission.

@jmodjeski75
Copy link
Contributor Author

jmodjeski75 commented Jun 5, 2019

why doesn't it set that URL in the origin of the repo.

Where is this documented?
Because this would not be necessary
https://github.com/semantic-release/semantic-release/blob/master/lib/get-git-auth-url.js#L17

Before this PR, the git ls-remote was called with origin in order to use whatever remote URL the CI uses which should at least gives read permission.

no it assumed there was a remote named origin

@semantic-release-bot
Copy link
Collaborator

🎉 This PR is included in version 16.0.0-beta.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

@pvdlg
Copy link
Member

pvdlg commented Jun 5, 2019

Where is this documented?

What do you mean? In the your CI doc? I don't know.
It's the way that every CI I tested works. It doesn't make much sense for the CI to set the origin as an URL that doesn't works.

What CI are you using?

no it assumed there was a remote named origin

I don't know is assumed is the right term here. Every repo on which semantic-release would run is a local clone and calling git clone <some_url> setts the origin to <some_url>.

It seems your CI, for some reason calls git clone <auth_url> and then git remote set-url origin <non_auth_url>. I don't see what's the point of doing that.

@jmodjeski75
Copy link
Contributor Author

jmodjeski75 commented Jun 5, 2019

What do you mean? In the your CI doc? I don't know.

Here in this repository, no where in the docs does it indict having to call git remote add origin <auth_url> if this were true, this would not be necessary. If the consumer, CI or not, should explicitly have a remote named origin and set to the appropriate url for both git fetch and git push it should be clearly documented.
But based on the documentation here that convenience of figuring out which auth scheme to use and what the correct repository url with auth for git fetch and git push should be is provided but if that is incorrect, remove, close the loop.

@pvdlg
Copy link
Member

pvdlg commented Jun 5, 2019

I tested semantic-release on something like 20 different CI. All of them set the origin of the cloned repo as a URL that has read access to the repo. Some use and ssh key, some other use use an URL formatted with credentials, but they all make sure you can run git commands that read the repo without having to do anything (if you don't specify a URL git will use origin by default).

This is why the doc doesn't say to call git remote add origin <auth_url> because for the CIs I tested it's not necessary. Setting the origin of the repo to an URL that is unusable doesn't make sense to me, this is why I assumed this case would never happen. Your issue is the first occurence of this problem.

It seems your CI behave differently. Again, what CI are you using?

@jmodjeski75
Copy link
Contributor Author

jmodjeski75 commented Jun 5, 2019

(if you don't specify a URL git will use origin by default).

sure but the repository may not have a remote called origin but I digress. See git remove.
IE. git remove remove origin or git remove rm origin

It seems your CI behave differently. Again, what CI are you using?

I am using Jenkins
#1156 - TeamCity
#1170 - a docker based CI of some kind

@alexan
Copy link

alexan commented Jun 6, 2019

yes jenkins uses different git authentication, for checkout and for what is available, when you use git binary directly. It even gets more complicated, when the pipeline is running in a docker container,

@alexan
Copy link

alexan commented Jun 6, 2019

I don't know if these changes are connected. But after updating and usage of beta-20 in a existing project I got another error: #1199

@semantic-release-bot
Copy link
Collaborator

🎉 This PR is included in version 16.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants