siemens / kas

Setup tool for bitbake based projects
MIT License
339 stars 145 forks source link

git https token problem #109

Closed embetrix closed 4 months ago

embetrix commented 4 months ago

Hello, I have the following kas project file to build locally using git over ssh authentication which is working fine :

  meta-example:
  poky:
    url: "ssh://git@git.gitlab.com/example-yocto/poky.git"
    refspec: kirkstone
    path: "layers"
    layers:
      meta:
      meta-poky:
  meta-openembedded:
    url: "ssh://git@git.gitlab.com/example-yocto/meta-openembedded.git"
    refspec: kirkstone
    path: "layers/meta-openembedded"
    layers:
      meta-oe:
      meta-python:
      meta-networking:
      meta-perl:
      meta-python:
      meta-filesystems:
      meta-webserver:
  meta-swupdate:
    url: "ssh://git@git.gitlab.com/example-yocto/meta-swupdate.git"
    refspec: kirkstone
    path: "layers/meta-swupdate"
  meta-gplv2:
    url: "ssh://git@git.gitlab.com/example-yocto/meta-gplv2.git"
    refspec: kirkstone
    path: "layers/meta-gplv2"

But on my CI build I would like to use gitlab token instead of SSH so I set the following :

$ cat ~/.gitconfig
[url "https://oauth2:glpat-xxxxxxxxxx@git.gitlab.com/"]
    insteadOf = ssh://git@git.gitlab.com/
$ KAS_MACHINE=stm32mp157c-dk2 KAS_TARGET=some-image kas build kas-example.yml

2024-02-19 15:25:32 - INFO     - kas 4.0 started
2024-02-19 15:25:32 - INFO     - /yocto/meta-example$ git rev-parse --show-toplevel
2024-02-19 15:25:32 - INFO     - /yocto/meta-example$ git rev-parse --show-toplevel
2024-02-19 15:25:32 - INFO     - /yocto/meta-example$ git rev-parse --show-toplevel
2024-02-19 15:25:32 - INFO     - Using /yocto/meta-example as root for repository meta-example
2024-02-19 15:25:32 - WARNING  - Using deprecated refspec for repository "poky". You should migrate to commit/branch.
2024-02-19 15:25:32 - WARNING  - Using deprecated refspec for repository "meta-openembedded". You should migrate to commit/branch.
2024-02-19 15:25:32 - WARNING  - Using deprecated refspec for repository "meta-swupdate". You should migrate to commit/branch.
2024-02-19 15:25:32 - WARNING  - Using deprecated refspec for repository "meta-gplv2". You should migrate to commit/branch.
2024-02-19 15:25:32 - INFO     - /yocto/meta-example$ git clone -q ssh://git@git.gitlab.com/yocto/poky.git /yocto/meta-example/layers
2024-02-19 15:25:32 - INFO     - /yocto/meta-example$ git clone -q ssh://git@git.gitlab.com/yocto/meta-openembedded.git /yocto/meta-example/layers/meta-openembedded
2024-02-19 15:25:32 - INFO     - /yocto/meta-example$ git clone -q ssh://git@git.gitlab.com/yocto/meta-swupdate.git /yocto/meta-example/layers/meta-swupdate
2024-02-19 15:25:32 - INFO     - /yocto/meta-example$ git clone -q ssh://git@git.gitlab.com/yocto/meta-gplv2.git /yocto/meta-example/layers/meta-gplv2
2024-02-19 15:25:32 - ERROR    - Host key verification failed.
2024-02-19 15:25:32 - ERROR    - fatal: Could not read from remote repository.
2024-02-19 15:25:32 - ERROR    - 
2024-02-19 15:25:32 - ERROR    - Please make sure you have the correct access rights
2024-02-19 15:25:32 - ERROR    - and the repository exists.
2024-02-19 15:25:32 - ERROR    - Command "/yocto/meta-example$ git clone -q ssh://git@git.gitlab.com/yocto/meta-openembedded.git /yocto/meta-example/layers/meta-openembedded" failed
--- Error summary ---
Host key verification failed.
fatal: Could not read from remote repository.

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

Any advice on how this scenario should works ?

embetrix commented 4 months ago

Answer to my own question

setting the env variable KAS_PREMIRRORS do the trick:

KAS_PREMIRRORS="ssh://git@git.gitlab.com/ https://oauth2:glpat-XXXXXXXXXXXX@git.gitlab.com/"