firecow / gitlab-ci-local

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

includes not working as expected with custom ssh port #1081

Closed WladyX closed 9 months ago

WladyX commented 9 months ago

Minimal .gitlab-ci.yml illustrating the issue

include:
  - project: "wxs/pipelines"
    ref: main
    file: "packer.yml"

variables:
  PACKER_VER: "latest"
  PACKER_ROOT: ${CI_PROJECT_DIR}/debian12
  PACKER_RG: packer_build_debian12-cube
  PKR_VAR_vm_id: "900"
  PKR_VAR_proxmox_node: "cube"

Expected behavior i would expect the list of jobs

Host information MacOS 14.2 gitlab-ci-local 4.46.0

Containerd binary OrbStack

Additional context

gitlab-ci-local --fetch-includes
parsing and downloads finished in 98 ms

no errror reported but the folders are empty:

tree .gitlab-ci-local
.gitlab-ci-local
└── includes
    └── gitlab.mydomain.com
        └── wxs
            └── pipelines
                └── main

6 directories, 0 files

my remote is:

git remote -v
origin  git@gitlab.mydomain.com:wxs/sched/packerox.git (fetch)
origin  git@gitlab.mydomain.com:wxs/sched/packerox.git (push)
gitlab-ci-local --list
parsing and downloads finished in 92 ms
jobNamePad is uninitialized

i guess this is expected because the include is not downloaded.

any ideeas on what i am doing wrong or what i could try? thank you

firecow commented 9 months ago

Includes from my self hosted gitlab gets downloaded just fine.

Can you show the contents of your packer.yml?

WladyX commented 9 months ago
cat packer.yml
include:
  - helper/runonly.yml
  - helper/tags_cc.yml
  - helper/notifier.yml
  - helper/cleanup_jobs.yml
  - helper/stages.yml

  - packer/vars.yml
  - packer/validate.yml
  - packer/build.yml

is there any verbose/debug flag i could use to get more logs? thank you for your support!

WladyX commented 9 months ago

I've replaced the above suspecting maybe there is an issue with include with the following:

cat packer.yml
build-job:
  stage: build
  script:
    - echo "Hello, $GITLAB_USER_LOGIN!"

test-job1:
  stage: test
  script:
    - echo "This job tests something"

test-job2:
  stage: test
  script:
    - echo "This job tests something, but takes more time than test-job1."
    - echo "After the echo commands complete, it runs the sleep command for 20 seconds"
    - echo "which simulates a test that runs 20 seconds longer than test-job1"
    - sleep 20

deploy-prod:
  stage: deploy
  script:
    - echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
  environment: production

pushed to the pipelines repo, did not make any difference.

WladyX commented 9 months ago

Ok, i found the issue, i use a custom ssh port and i have specified that in ~/.ssh/config:

Host gitlab.mydomain.com
        Port 2222

looks like gitlab-ci-local is ignoring this. i modified the remote like this:

/packerox $ cat .git/config|grep url -B1
[remote "origin"]
    #url = git@gitlab.mydomain.com:wxs/sched/packerox.git
    url = git@gitlab.mydomain.com:2222/wxs/sched/packerox.git

and gitlab-ci-local started to work.

So question becomes now: is it possible to make gitlab-ci-local respect ~/.ssh/config in the same way that git does ?

firecow commented 9 months ago

We are going to rely solely on git remote -v for getting include URLs.

But I will investigate, why you werent seeing any real error messages printed.

Don't wanna snoop around in peoples ssh dirs

WladyX commented 9 months ago

thing is that with the url modified git does not work for some reason, git-ci-local works, but git does not:

remote:
remote: ========================================================================
remote:
remote: The project you were looking for could not be found or you don't have permission to view it.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

can i override the remote only for gitlab-ci-local?

firecow commented 9 months ago

Not that I know of.

A --remote-gitlab-url cli option feature request will be pretty easy to implement.

WladyX commented 9 months ago

Cool, should i create an issue for that, or you'll keep it in mind? In my case i think a --remote-port would be more useful as i could add it to the zsh alias as it is common for all projects. For --remote-gitlab-url i would need to specify for each project, but any of them would be very useful for me. Thank you!

firecow commented 9 months ago

Make a feature request issue, for what ever feature you would like 🤣