woodpecker-ci / woodpecker

Woodpecker is a simple yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
3.95k stars 351 forks source link

Add custom SSH config when clone via SSH instead of HTTP #2496

Closed sinlov closed 5 months ago

sinlov commented 10 months ago

Clear and concise description of the problem

Currently woodpecker clones the repositories via HTTP, but some git ssh config must use custom config.

Suggested solution

  1. create custom ssh config as file map
.
└── default
    ├── config
    ├── id_rsa
    └── known_hosts
  1. setting woodpecker-agent arg WOODPECKER_CUSTOM_SSH_GROUP_ROOT

  2. config

pipeline:
  clone:
    image: woodpeckerci/plugin-git
    settings:
      custom_ssh_group:
        name: default
        dryrun_host: host_name # optional
  1. at clone step

Alternative

.
├── bar
│   ├── config
│   ├── id_rsa
│   └── known_hosts
├── default
│   ├── config
│   ├── id_rsa
│   └── known_hosts
└── foo
    ├── config
    ├── id_rsa
    └── known_hosts
.
└── default
    ├── config
    ├── id_rsa
    └── known_hosts
pipeline:
  clone:
    image: woodpeckerci/plugin-git
    settings:
      custom_ssh_group:
        name: default
        dryrun_host: host_name # optional

beacuse settings. ssh_key args (type string) is change git config core.sshCommand ssh -i <key>, don not use at same time

Additional context

No response

Validations

qwerty287 commented 8 months ago

In 2.0.0, plugin-git supports ssh cloning. It must be enabled manually. Does this fix the issue? (See https://github.com/woodpecker-ci/plugin-git/pull/75)

sinlov commented 5 months ago

@qwerty287 version 2.x

with local backend mode, support clone via SSH instead of HTTP can change git global config like this

git config --global url."git@git.xxx.com:".insteadOf "https://git.xxx.com/"

so, please close this issure