firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.28k stars 128 forks source link

Gcl use my username as host in includes #1178

Closed comm1x closed 4 months ago

comm1x commented 6 months ago

Minimal .gitlab-ci.yml illustrating the issue

include:
  - project: 'myrepo/myapp'
    ref: 'master'
    file:
      - 'config.yml'

Expected behavior GCL download config.yml from Gitlab and use it.

Actual behavior GCL use my username as remote.host and failed with error

Project include could not be fetched 
fatal: unable to access 'https://p.shorokhov/myrepo/myapp.git/': Could not resolve host: p.shorokhov

Host information Macos gitlab-ci-local 4.47.0

Containerd binary Docker

Gcl failed in this git clone command: https://github.com/firecow/gitlab-ci-local/blob/c6d78471ca2b4305572cc31b131f96cb6416bd5e/src/parser-includes.ts#L190

firecow commented 5 months ago

Paste your ~/.gitlab-ci-local/variables.yml, env | grep GCL_, <project>/.gitlab-ci-local-env and cd <project>/ && git remote -v (Mask your secrets)

Is you gitlab instance actually located on https://p.shorokhov ?

Also this https://github.com/firecow/gitlab-ci-local?tab=readme-ov-file#quirks image

comm1x commented 5 months ago

~/.gitlab-ci-local not exists

env | grep GCL_ empty

$project/.gitlab-ci-local-env: VARIABLE="CI_JOB_TOKEN=... CI_PIPELINE_SOURCE=merge_request_event CI_MERGE_REQUEST_ID=1"

git remote -v:

origin  ssh://git@gitlab.mydomain.ru:5555/myrepo/myapp.git (fetch)
origin  ssh://git@gitlab.mydomain.ru:5555/myrepo/myapp.git (push)

Is you gitlab instance actually located on https://p.shorokhov ?

No, this is my username. Gitlab is on gitlab.mydomain.ru

UPD: It is wrong, https://github.com/firecow/gitlab-ci-local/issues/1178#issuecomment-2068822175

firecow commented 5 months ago

You must have some setting somewhere in the <project>/.git, global git settings, or gitlab-ci-local variables or env settings, that makes gitlab-ci-local resolve https://p.shorokhov as being the place to go.

comm1x commented 5 months ago

I have User p.shorokhov in .ssh/config in gitlab host. Can't find any other entries.

ANGkeith commented 5 months ago

@comm1x

Are you showing your full git remote -v ?

Is this the error you're seeing? image

ANGkeith commented 5 months ago

https://github.com/firecow/gitlab-ci-local/blob/03879cdb17c66fe602f20e6e2bc6e0651861efc3/src/git-data.ts#L85

@firecow instead of git remote -v shall we hard-codegit remote get-url origin

comm1x commented 5 months ago

@ANGkeith thanks for you comment, I posted wrong data from .git/config above.

The problem related with usage https in origin configuration in .git/config:

[remote "origin"]
    # This is not working  
    url = https://p.shorokhov:sometoken@gitlab.mydomain.ru/myrepo/myproject.git

    # This works correctly
    url = ssh://git@gitlab.mydomain.ru:5555/myrepo/myproject.git
comm1x commented 5 months ago

@comm1x

Are you showing your full git remote -v ?

Is this the error you're seeing? image

Yes, this is equal error.

firecow commented 5 months ago

https://github.com/firecow/gitlab-ci-local/blob/03879cdb17c66fe602f20e6e2bc6e0651861efc3/src/git-data.ts#L85

@firecow instead of git remote -v shall we hard-codegit remote get-url origin

If this command works better, sure :smile:

ANGkeith commented 4 months ago

https://github.com/firecow/gitlab-ci-local/pull/1202 should fix this problem

also note that the remote-url is customizable via git remote add-url gcl-origin