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

Bug: Remote URL's Formatting Error #40

Closed
Blackglade opened this issue Mar 9, 2020 · 7 comments
Closed

Bug: Remote URL's Formatting Error #40

Blackglade opened this issue Mar 9, 2020 · 7 comments
Labels

Comments

@Blackglade
Copy link

Blackglade commented Mar 9, 2020

Description

I had several builds fail this morning as they tried to push GitHub code to a repo via a drone pipeline. The error occurred in the final step of my pipeline:

  - name: Publish website
    image: appleboy/drone-git-push
    settings:
      remote_name: test_repo
      remote: git@custom_url.com:test/test.git
      branch: gh-pages
      path: /drone/src/website
      key: GIT_PUSH_SSH_KEY
      force: true
    environment:
      GIT_PUSH_SSH_KEY:
        from_secret: GIT_PUSH_SSH_KEY

The error was as follows:

time="2020-03-09T18:33:42Z" level=fatal msg="parse \"git@custom_url.com:test/test.git\": first path segment in URL cannot contain colon"

This is likely occurring because a regression of a previous issue with net/url in 1.14. See this issue: golang/go#29261

Changing the image from appleboy/drone-git-push to appleboy/drone-git-push:0.2.0-linux-alpine to migrate to the last working version resolved the issue.

@appleboy
Copy link
Owner

I will take it.

@appleboy appleboy added the bug label Mar 10, 2020
@Blackglade
Copy link
Author

Awesome! Thanks again! Any idea of an eta till a fix is released?

@decentral1se
Copy link

Yeah, running into this... using "bar@foo.com:repo.git"

@decentral1se
Copy link

decentral1se commented Mar 25, 2020

Work-around is: image: appleboy/drone-git-push:0.2.0-linux-amd64

@emadzz
Copy link

emadzz commented Nov 4, 2020

The workaround suggested by decentral1se works for me, but are there any plans to fix this in a "latest" version/tag?

@satwell
Copy link

satwell commented Dec 17, 2020

Pretty sure this is unrelated to the linked golang bug. That bug is specifically about leading space in front of URLs passed to url.Parse. I'm pretty sure this is a bug related to repo.WriteToken introduced in ca3840a.

repo.WriteToken calls url.Parse, and url.Parse will (correctly) fail because a string like git@github.com:foo/bar is not a valid absolute or relative URL.

So a workaround would be to specify remote in SSH URL format: ssh://git@github.com/user/repo.git. Note that there's a slash between the hostname and the username, not a colon.

It looks like people will only run into this issue if Drone uses authentication for the clone step, e.g., you're running on a private repo or you set DRONE_GIT_ALWAYS_AUTH=true in your Drone server config. In this case, Drone writes credentials into DRONE_NETRC_*, which activates drone-git-push's repo.WriteToken.

@appleboy
Copy link
Owner

appleboy commented Aug 2, 2022

Thanks for @satwell solution

replace

git@github.com:fh-trier/latex-templates.git

with

ssh://git@github.com/fh-trier/latex-templates.git

@appleboy appleboy closed this as completed Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants